updated build system
This commit is contained in:
@ -26,10 +26,6 @@
|
|||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
namespace repertory::utils::file {
|
namespace repertory::utils::file {
|
||||||
// Prototypes
|
|
||||||
[[nodiscard]] auto calculate_used_space(std::string path,
|
|
||||||
bool recursive) -> std::uint64_t;
|
|
||||||
|
|
||||||
void change_to_process_directory();
|
void change_to_process_directory();
|
||||||
|
|
||||||
[[nodiscard]] auto copy_directory_recursively(std::string from_path,
|
[[nodiscard]] auto copy_directory_recursively(std::string from_path,
|
||||||
@ -66,10 +62,6 @@ is_modified_date_older_than(const std::string &path,
|
|||||||
read_file_lines(const std::string &path) -> std::vector<std::string>;
|
read_file_lines(const std::string &path) -> std::vector<std::string>;
|
||||||
|
|
||||||
[[nodiscard]] auto reset_modified_time(const std::string &path) -> bool;
|
[[nodiscard]] auto reset_modified_time(const std::string &path) -> bool;
|
||||||
|
|
||||||
[[nodiscard]] auto retry_delete_directory(const std::string &dir) -> bool;
|
|
||||||
|
|
||||||
[[nodiscard]] auto retry_delete_file(const std::string &file) -> bool;
|
|
||||||
} // namespace repertory::utils::file
|
} // namespace repertory::utils::file
|
||||||
|
|
||||||
#endif // INCLUDE_UTILS_FILE_UTILS_HPP_
|
#endif // INCLUDE_UTILS_FILE_UTILS_HPP_
|
||||||
|
@ -92,7 +92,7 @@ void eviction::service_function() {
|
|||||||
|
|
||||||
// Handle maximum cache size eviction
|
// Handle maximum cache size eviction
|
||||||
auto used_bytes =
|
auto used_bytes =
|
||||||
utils::file::calculate_used_space(config_.get_cache_directory(), false);
|
utils::file::directory{config_.get_cache_directory()}.size();
|
||||||
if (config_.get_enable_max_cache_size()) {
|
if (config_.get_enable_max_cache_size()) {
|
||||||
should_evict = (used_bytes > config_.get_max_cache_size_bytes());
|
should_evict = (used_bytes > config_.get_max_cache_size_bytes());
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ auto file_manager::evict_file(const std::string &api_path) -> bool {
|
|||||||
|
|
||||||
open_file_lookup_.erase(api_path);
|
open_file_lookup_.erase(api_path);
|
||||||
|
|
||||||
auto removed = utils::file::retry_delete_file(source_path);
|
auto removed = utils::file::file(source_path).remove();
|
||||||
if (removed) {
|
if (removed) {
|
||||||
event_system::instance().raise<filesystem_item_evicted>(api_path,
|
event_system::instance().raise<filesystem_item_evicted>(api_path,
|
||||||
source_path);
|
source_path);
|
||||||
@ -513,8 +513,8 @@ void file_manager::queue_upload(const std::string &api_path,
|
|||||||
db::db_insert{*db_.get(), upload_table}
|
db::db_insert{*db_.get(), upload_table}
|
||||||
.or_replace()
|
.or_replace()
|
||||||
.column_value("api_path", api_path)
|
.column_value("api_path", api_path)
|
||||||
.column_value("date_time", static_cast<std::int64_t>(
|
.column_value("date_time",
|
||||||
utils::time::get_time_now()))
|
static_cast<std::int64_t>(utils::time::get_time_now()))
|
||||||
.column_value("source_path", source_path)
|
.column_value("source_path", source_path)
|
||||||
.go();
|
.go();
|
||||||
if (result.ok()) {
|
if (result.ok()) {
|
||||||
@ -557,7 +557,7 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not utils::file::retry_delete_file(fsi.source_path)) {
|
if (not utils::file::file(fsi.source_path).remove()) {
|
||||||
utils::error::raise_api_path_error(
|
utils::error::raise_api_path_error(
|
||||||
function_name, fsi.api_path, fsi.source_path,
|
function_name, fsi.api_path, fsi.source_path,
|
||||||
utils::get_last_error_code(), "failed to delete source");
|
utils::get_last_error_code(), "failed to delete source");
|
||||||
@ -780,7 +780,7 @@ auto file_manager::rename_file(const std::string &from_api_path,
|
|||||||
|
|
||||||
res = remove_file(to_api_path);
|
res = remove_file(to_api_path);
|
||||||
if ((res == api_error::success) || (res == api_error::item_not_found)) {
|
if ((res == api_error::success) || (res == api_error::item_not_found)) {
|
||||||
if (not utils::file::retry_delete_file(fsi.source_path)) {
|
if (not utils::file::file(fsi.source_path).remove()) {
|
||||||
utils::error::raise_api_path_error(
|
utils::error::raise_api_path_error(
|
||||||
function_name, fsi.api_path, fsi.source_path,
|
function_name, fsi.api_path, fsi.source_path,
|
||||||
utils::get_last_error_code(), "failed to delete source path");
|
utils::get_last_error_code(), "failed to delete source path");
|
||||||
|
@ -458,7 +458,7 @@ auto file_manager::open_file::close() -> bool {
|
|||||||
mgr_.store_resume(*this);
|
mgr_.store_resume(*this);
|
||||||
} else if (get_api_error() != api_error::success) {
|
} else if (get_api_error() != api_error::success) {
|
||||||
mgr_.remove_resume(get_api_path(), get_source_path());
|
mgr_.remove_resume(get_api_path(), get_source_path());
|
||||||
if (not utils::file::retry_delete_file(fsi_.source_path)) {
|
if (not utils::file::file(fsi_.source_path).remove()) {
|
||||||
utils::error::raise_api_path_error(
|
utils::error::raise_api_path_error(
|
||||||
function_name, get_api_path(), fsi_.source_path,
|
function_name, get_api_path(), fsi_.source_path,
|
||||||
utils::get_last_error_code(), "failed to delete file");
|
utils::get_last_error_code(), "failed to delete file");
|
||||||
|
@ -93,7 +93,7 @@ file_manager::ring_buffer_open_file::~ring_buffer_open_file() {
|
|||||||
close();
|
close();
|
||||||
|
|
||||||
nf_->close();
|
nf_->close();
|
||||||
if (not utils::file::retry_delete_file(fsi_.source_path)) {
|
if (not utils::file::file(fsi_.source_path).remove()) {
|
||||||
utils::error::raise_api_path_error(
|
utils::error::raise_api_path_error(
|
||||||
function_name, fsi_.api_path, fsi_.source_path,
|
function_name, fsi_.api_path, fsi_.source_path,
|
||||||
utils::get_last_error_code(), "failed to delete file");
|
utils::get_last_error_code(), "failed to delete file");
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
#include "rpc/server/full_server.hpp"
|
#include "rpc/server/full_server.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "drives/directory_iterator.hpp"
|
|
||||||
#include "file_manager/i_file_manager.hpp"
|
#include "file_manager/i_file_manager.hpp"
|
||||||
#include "providers/i_provider.hpp"
|
#include "providers/i_provider.hpp"
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "types/rpc.hpp"
|
#include "types/rpc.hpp"
|
||||||
#include "utils/file_utils.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "utils/path.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
@ -51,11 +50,11 @@ void full_server::handle_get_directory_items(const httplib::Request &req,
|
|||||||
|
|
||||||
void full_server::handle_get_drive_information(const httplib::Request & /*req*/,
|
void full_server::handle_get_drive_information(const httplib::Request & /*req*/,
|
||||||
httplib::Response &res) {
|
httplib::Response &res) {
|
||||||
|
auto dir_size =
|
||||||
|
utils::file::directory(get_config().get_cache_directory()).size();
|
||||||
res.set_content(
|
res.set_content(
|
||||||
json({
|
json({
|
||||||
{"cache_space_used",
|
{"cache_space_used", dir_size},
|
||||||
utils::file::calculate_used_space(
|
|
||||||
get_config().get_cache_directory(), false)},
|
|
||||||
{"drive_space_total", provider_.get_total_drive_space()},
|
{"drive_space_total", provider_.get_total_drive_space()},
|
||||||
{"drive_space_used", provider_.get_used_drive_space()},
|
{"drive_space_used", provider_.get_used_drive_space()},
|
||||||
{"item_count", provider_.get_total_item_count()},
|
{"item_count", provider_.get_total_item_count()},
|
||||||
|
@ -30,56 +30,6 @@
|
|||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
|
|
||||||
namespace repertory::utils::file {
|
namespace repertory::utils::file {
|
||||||
auto calculate_used_space(std::string path, bool recursive) -> std::uint64_t {
|
|
||||||
path = utils::path::absolute(path);
|
|
||||||
std::uint64_t ret{};
|
|
||||||
#if defined(_WIN32)
|
|
||||||
WIN32_FIND_DATA fd{};
|
|
||||||
const auto search = utils::path::combine(path, {"*.*"});
|
|
||||||
auto find = ::FindFirstFile(search.c_str(), &fd);
|
|
||||||
if (find != INVALID_HANDLE_VALUE) {
|
|
||||||
do {
|
|
||||||
const auto file_name = std::string(fd.cFileName);
|
|
||||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
|
||||||
if (recursive && (file_name != ".") && (file_name != "..")) {
|
|
||||||
ret += calculate_used_space(utils::path::combine(path, {file_name}),
|
|
||||||
recursive);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
std::uint64_t file_size{};
|
|
||||||
if (get_file_size(utils::path::combine(path, {file_name}), file_size)) {
|
|
||||||
ret += file_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (::FindNextFile(find, &fd) != 0);
|
|
||||||
::FindClose(find);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
auto *root = opendir(path.c_str());
|
|
||||||
if (root) {
|
|
||||||
struct dirent *de{};
|
|
||||||
while ((de = readdir(root)) != nullptr) {
|
|
||||||
if (de->d_type == DT_DIR) {
|
|
||||||
if (recursive && (strcmp(de->d_name, ".") != 0) &&
|
|
||||||
(strcmp(de->d_name, "..") != 0)) {
|
|
||||||
ret += calculate_used_space(utils::path::combine(path, {de->d_name}),
|
|
||||||
recursive);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
std::uint64_t file_size{};
|
|
||||||
if (get_file_size(utils::path::combine(path, {de->d_name}),
|
|
||||||
file_size)) {
|
|
||||||
ret += file_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir(root);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void change_to_process_directory() {
|
void change_to_process_directory() {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
std::string file_name;
|
std::string file_name;
|
||||||
@ -459,24 +409,4 @@ auto reset_modified_time(const std::string &path) -> bool {
|
|||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto retry_delete_directory(const std::string &dir) -> bool {
|
|
||||||
auto deleted = false;
|
|
||||||
for (std::uint8_t i = 0U;
|
|
||||||
not(deleted = directory(dir).remove()) && (i < 200U); i++) {
|
|
||||||
std::this_thread::sleep_for(10ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto retry_delete_file(const std::string &file) -> bool {
|
|
||||||
auto deleted = false;
|
|
||||||
for (std::uint8_t i = 0U;
|
|
||||||
not(deleted = utils::file::file{file}.remove()) && (i < 200U); i++) {
|
|
||||||
std::this_thread::sleep_for(10ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deleted;
|
|
||||||
}
|
|
||||||
} // namespace repertory::utils::file
|
} // namespace repertory::utils::file
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||||
#include "backward.hpp"
|
#include "backward.hpp"
|
||||||
#endif
|
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||||
|
|
||||||
#include "cli/actions.hpp"
|
#include "cli/actions.hpp"
|
||||||
#include "initialize.hpp"
|
#include "initialize.hpp"
|
||||||
@ -34,7 +34,7 @@ using namespace repertory;
|
|||||||
auto main(int argc, char **argv) -> int {
|
auto main(int argc, char **argv) -> int {
|
||||||
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||||
static backward::SignalHandling sh;
|
static backward::SignalHandling sh;
|
||||||
#endif
|
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||||
|
|
||||||
if (not repertory::project_initialize()) {
|
if (not repertory::project_initialize()) {
|
||||||
std::cerr << "fatal: failed to initialize repertory" << std::endl;
|
std::cerr << "fatal: failed to initialize repertory" << std::endl;
|
||||||
|
@ -132,7 +132,7 @@ public:
|
|||||||
utils::path::combine(mount_location_, {to_api_path});
|
utils::path::combine(mount_location_, {to_api_path});
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
if (not utils::file::retry_delete_file(to_file_path)) {
|
if (not utils::file::file(to_file_path).remove()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (utils::file::directory(to_file_path).exists()) ||
|
} else if (utils::file::directory(to_file_path).exists()) ||
|
||||||
|
@ -431,8 +431,8 @@ namespace repertory {
|
|||||||
// // utils::path::combine(mount_location, {"to_rename_file_test"});
|
// // utils::path::combine(mount_location, {"to_rename_file_test"});
|
||||||
// // test_rename_file(file_path, to_file_path,
|
// // test_rename_file(file_path, to_file_path,
|
||||||
// // provider_ptr->is_rename_supported());
|
// // provider_ptr->is_rename_supported());
|
||||||
// // EXPECT_TRUE(utils::file::retry_delete_file(file_path));
|
// // EXPECT_TRUE(utils::file::file(file_path).remove());
|
||||||
// // EXPECT_TRUE(utils::file::retry_delete_file(to_file_path));
|
// // EXPECT_TRUE(utils::file::file(to_file_path).remove());
|
||||||
// //
|
// //
|
||||||
// // file_path =
|
// // file_path =
|
||||||
// // utils::path::combine(mount_location,
|
// // utils::path::combine(mount_location,
|
||||||
|
@ -52,7 +52,7 @@ static std::string fuse_remote_dir =
|
|||||||
static void access_test(repertory::remote_fuse::remote_client &client) {
|
static void access_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"access.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"access.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -64,13 +64,13 @@ static void access_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_access(api_path.c_str(), 0));
|
EXPECT_EQ(0, client.fuse_access(api_path.c_str(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chflags_test(repertory::remote_fuse::remote_client &client) {
|
static void chflags_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"chflags.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"chflags.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -86,13 +86,13 @@ static void chflags_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chmod_test(repertory::remote_fuse::remote_client &client) {
|
static void chmod_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"chmod.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"chmod.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -108,13 +108,13 @@ static void chmod_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chown_test(repertory::remote_fuse::remote_client &client) {
|
static void chown_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"chown.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"chown.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -134,7 +134,7 @@ static void chown_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -143,7 +143,7 @@ create_and_release_test(repertory::remote_fuse::remote_client &client,
|
|||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"create_and_release.txt"});
|
utils::path::combine(fuse_remote_dir, {"create_and_release.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -156,7 +156,7 @@ create_and_release_test(repertory::remote_fuse::remote_client &client,
|
|||||||
EXPECT_EQ(0u, server.get_open_file_count(test_file));
|
EXPECT_EQ(0u, server.get_open_file_count(test_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_test(repertory::remote_fuse::remote_client &client) {
|
static void destroy_test(repertory::remote_fuse::remote_client &client) {
|
||||||
@ -167,7 +167,7 @@ static void destroy_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file = utils::path::combine(fuse_remote_dir,
|
const auto test_file = utils::path::combine(fuse_remote_dir,
|
||||||
{"fallocate.txt"}); const auto api_path =
|
{"fallocate.txt"}); const auto api_path =
|
||||||
test_file.substr(mount_location_.size());
|
test_file.substr(mount_location_.size());
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -181,14 +181,14 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
|||||||
EXPECT_EQ(100, file_size);
|
EXPECT_EQ(100, file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static void fgetattr_test(repertory::remote_fuse::remote_client &client) {
|
static void fgetattr_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"fgetattr.txt"});
|
utils::path::combine(fuse_remote_dir, {"fgetattr.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -228,14 +228,14 @@ static void fgetattr_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
st.st_birthtimespec / NANOS_PER_SECOND);
|
st.st_birthtimespec / NANOS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fsetattr_x_test(repertory::remote_fuse::remote_client &client) {
|
static void fsetattr_x_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"fsetattr_x.txt"});
|
utils::path::combine(fuse_remote_dir, {"fsetattr_x.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -253,13 +253,13 @@ static void fsetattr_x_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fsync_test(repertory::remote_fuse::remote_client &client) {
|
static void fsync_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"fsync.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"fsync.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -271,14 +271,14 @@ static void fsync_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ftruncate_test(repertory::remote_fuse::remote_client &client) {
|
static void ftruncate_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"ftruncate.txt"});
|
utils::path::combine(fuse_remote_dir, {"ftruncate.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -294,13 +294,13 @@ static void ftruncate_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(100U, opt_size.value());
|
EXPECT_EQ(100U, opt_size.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getattr_test(repertory::remote_fuse::remote_client &client) {
|
static void getattr_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"getattr.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"getattr.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -339,14 +339,14 @@ static void getattr_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
st.st_birthtimespec / NANOS_PER_SECOND);
|
st.st_birthtimespec / NANOS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static void getxattr_test(repertory::remote_fuse::remote_client &client) {
|
/*static void getxattr_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir,
|
const auto test_file = utils::path::combine(fuse_remote_dir,
|
||||||
{"getxattr.txt"}); const auto api_path =
|
{"getxattr.txt"}); const auto api_path =
|
||||||
test_file.substr(mount_location_.size());
|
test_file.substr(mount_location_.size());
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -359,14 +359,14 @@ nullptr, 0)); #else EXPECT_EQ(-EACCES, client.fuse_getxattr(api_path.c_str(),
|
|||||||
"test", nullptr, 0)); #endif
|
"test", nullptr, 0)); #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getxattr_osx_test(repertory::remote_fuse::remote_client &client) {
|
static void getxattr_osx_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir,
|
const auto test_file = utils::path::combine(fuse_remote_dir,
|
||||||
{"getxattr_osx.txt"}); const auto api_path =
|
{"getxattr_osx.txt"}); const auto api_path =
|
||||||
test_file.substr(mount_location_.size());
|
test_file.substr(mount_location_.size());
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -377,14 +377,14 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
|||||||
client.fuse_getxattrOSX(api_path.c_str(), "test", nullptr, 0, 0));
|
client.fuse_getxattrOSX(api_path.c_str(), "test", nullptr, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static void getxtimes_test(repertory::remote_fuse::remote_client &client) {
|
static void getxtimes_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"getxtimes.txt"});
|
utils::path::combine(fuse_remote_dir, {"getxtimes.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -403,7 +403,7 @@ static void getxtimes_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_test(repertory::remote_fuse::remote_client &client) {
|
static void init_test(repertory::remote_fuse::remote_client &client) {
|
||||||
@ -414,7 +414,7 @@ static void init_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file = utils::path::combine(fuse_remote_dir,
|
const auto test_file = utils::path::combine(fuse_remote_dir,
|
||||||
{"listxattr.txt"}); const auto api_path =
|
{"listxattr.txt"}); const auto api_path =
|
||||||
test_file.substr(mount_location_.size());
|
test_file.substr(mount_location_.size());
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -427,7 +427,7 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static void mkdir_test(repertory::remote_fuse::remote_client &client) {
|
static void mkdir_test(repertory::remote_fuse::remote_client &client) {
|
||||||
@ -449,7 +449,7 @@ static void mkdir_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
static void open_test(repertory::remote_fuse::remote_client &client) {
|
static void open_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"open.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"open.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -471,7 +471,7 @@ static void open_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle2));
|
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle2));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -499,7 +499,7 @@ static void read_and_write_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"read_and_write.txt"});
|
utils::path::combine(fuse_remote_dir, {"read_and_write.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -517,7 +517,7 @@ static void read_and_write_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -525,7 +525,7 @@ read_and_write_base64_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"read_and_write_base64.txt"});
|
utils::path::combine(fuse_remote_dir, {"read_and_write_base64.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -544,7 +544,7 @@ read_and_write_base64_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void readdir_test(repertory::remote_fuse::remote_client &client) {
|
static void readdir_test(repertory::remote_fuse::remote_client &client) {
|
||||||
@ -579,7 +579,7 @@ static void readdir_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file = utils::path::combine(fuse_remote_dir,
|
const auto test_file = utils::path::combine(fuse_remote_dir,
|
||||||
{"removexattr.txt"}); const auto api_path =
|
{"removexattr.txt"}); const auto api_path =
|
||||||
test_file.substr(mount_location_.size());
|
test_file.substr(mount_location_.size());
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -592,7 +592,7 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
|||||||
"test")); #endif
|
"test")); #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static void rename_test(repertory::remote_fuse::remote_client &client) {
|
static void rename_test(repertory::remote_fuse::remote_client &client) {
|
||||||
@ -602,8 +602,8 @@ static void rename_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
const auto renamed_api_path =
|
const auto renamed_api_path =
|
||||||
renamed_test_file.substr(mount_location_.size());
|
renamed_test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(renamed_test_file));
|
EXPECT_TRUE(utils::file::file(renamed_test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -625,8 +625,8 @@ static void rename_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_TRUE(utils::file::file(renamed_test_file).exists());
|
EXPECT_TRUE(utils::file::file(renamed_test_file).exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(renamed_test_file));
|
EXPECT_TRUE(utils::file::file(renamed_test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmdir_test(repertory::remote_fuse::remote_client &client) {
|
static void rmdir_test(repertory::remote_fuse::remote_client &client) {
|
||||||
@ -652,7 +652,7 @@ static void setattr_x_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"setattr_x.txt"});
|
utils::path::combine(fuse_remote_dir, {"setattr_x.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -670,14 +670,14 @@ static void setattr_x_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setbkuptime_test(repertory::remote_fuse::remote_client &client) {
|
static void setbkuptime_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"setbkuptime.txt"});
|
utils::path::combine(fuse_remote_dir, {"setbkuptime.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -695,14 +695,14 @@ static void setbkuptime_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setchgtime_test(repertory::remote_fuse::remote_client &client) {
|
static void setchgtime_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"setchgtime.txt"});
|
utils::path::combine(fuse_remote_dir, {"setchgtime.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -720,14 +720,14 @@ static void setchgtime_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setcrtime_test(repertory::remote_fuse::remote_client &client) {
|
static void setcrtime_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"setcrtime.txt"});
|
utils::path::combine(fuse_remote_dir, {"setcrtime.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -745,7 +745,7 @@ static void setcrtime_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setvolname_test(repertory::remote_fuse::remote_client &client) {
|
static void setvolname_test(repertory::remote_fuse::remote_client &client) {
|
||||||
@ -756,7 +756,7 @@ static void setvolname_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file = utils::path::combine(fuse_remote_dir,
|
const auto test_file = utils::path::combine(fuse_remote_dir,
|
||||||
{"setxattr.txt"}); const auto api_path =
|
{"setxattr.txt"}); const auto api_path =
|
||||||
test_file.substr(mount_location_.size());
|
test_file.substr(mount_location_.size());
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -771,14 +771,14 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
|||||||
5, 0)); #endif
|
5, 0)); #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setxattr_osx_test(repertory::remote_fuse::remote_client &client) {
|
static void setxattr_osx_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir,
|
const auto test_file = utils::path::combine(fuse_remote_dir,
|
||||||
{"setxattr_osx.txt"}); const auto api_path =
|
{"setxattr_osx.txt"}); const auto api_path =
|
||||||
test_file.substr(mount_location_.size());
|
test_file.substr(mount_location_.size());
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -791,7 +791,7 @@ remote::open_flags::ReadWrite, handle); EXPECT_EQ(0, ret); if (ret == 0) {
|
|||||||
0));
|
0));
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::file::retry_delete_file(test_file);
|
utils::file::file(test_file).remove();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -853,7 +853,7 @@ static void truncate_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(fuse_remote_dir, {"truncate.txt"});
|
utils::path::combine(fuse_remote_dir, {"truncate.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -876,13 +876,13 @@ static void truncate_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(100U, opt_size.value());
|
EXPECT_EQ(100U, opt_size.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unlink_test(repertory::remote_fuse::remote_client &client) {
|
static void unlink_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"unlink.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"unlink.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -895,13 +895,13 @@ static void unlink_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_FALSE(utils::file::file(test_file).exists());
|
EXPECT_FALSE(utils::file::file(test_file).exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void utimens_test(repertory::remote_fuse::remote_client &client) {
|
static void utimens_test(repertory::remote_fuse::remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(fuse_remote_dir, {"utimens.txt"});
|
const auto test_file = utils::path::combine(fuse_remote_dir, {"utimens.txt"});
|
||||||
const auto api_path = test_file.substr(mount_location_.size());
|
const auto api_path = test_file.substr(mount_location_.size());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
|
|
||||||
remote::file_handle handle;
|
remote::file_handle handle;
|
||||||
const auto ret = client.fuse_create(
|
const auto ret = client.fuse_create(
|
||||||
@ -915,7 +915,7 @@ static void utimens_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(0, client.fuse_utimens(api_path.c_str(), tv, 0, 0));
|
EXPECT_EQ(0, client.fuse_utimens(api_path.c_str(), tv, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(remote_fuse, all_tests) {
|
TEST(remote_fuse, all_tests) {
|
||||||
|
@ -45,7 +45,7 @@ static std::string win_remote_dir =
|
|||||||
static void can_delete_test(remote_client &client) {
|
static void can_delete_test(remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(win_remote_dir, {"candelete.txt"});
|
utils::path::combine(win_remote_dir, {"candelete.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -58,14 +58,14 @@ static void can_delete_test(remote_client &client) {
|
|||||||
api_path.data()));
|
api_path.data()));
|
||||||
|
|
||||||
nf.close();
|
nf.close();
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename t>
|
template <typename t>
|
||||||
static void create_and_close_test(remote_client &client, t &server) {
|
static void create_and_close_test(remote_client &client, t &server) {
|
||||||
const auto test_file = utils::path::combine(win_remote_dir, {"create.txt"});
|
const auto test_file = utils::path::combine(win_remote_dir, {"create.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -83,12 +83,12 @@ static void create_and_close_test(remote_client &client, t &server) {
|
|||||||
EXPECT_EQ(0u, client.get_open_file_count(utils::string::to_utf8(api_path)));
|
EXPECT_EQ(0u, client.get_open_file_count(utils::string::to_utf8(api_path)));
|
||||||
EXPECT_EQ(0u, server.get_open_file_count(test_file));
|
EXPECT_EQ(0u, server.get_open_file_count(test_file));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup_test(remote_client &client) {
|
static void cleanup_test(remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(win_remote_dir, {"cleanup.txt"});
|
const auto test_file = utils::path::combine(win_remote_dir, {"cleanup.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -107,12 +107,12 @@ static void cleanup_test(remote_client &client) {
|
|||||||
EXPECT_FALSE(was_closed);
|
EXPECT_FALSE(was_closed);
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_test(remote_client &client) {
|
static void flush_test(remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(win_remote_dir, {"flush.txt"});
|
const auto test_file = utils::path::combine(win_remote_dir, {"flush.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -129,13 +129,13 @@ static void flush_test(remote_client &client) {
|
|||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_file_info_test(remote_client &client) {
|
static void get_file_info_test(remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(win_remote_dir, {"get_file_info.txt"});
|
utils::path::combine(win_remote_dir, {"get_file_info.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -152,13 +152,13 @@ static void get_file_info_test(remote_client &client) {
|
|||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_security_by_name_test(remote_client &client) {
|
static void get_security_by_name_test(remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(win_remote_dir, {"get_security_by_name.txt"});
|
utils::path::combine(win_remote_dir, {"get_security_by_name.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ static void get_security_by_name_test(remote_client &client) {
|
|||||||
EXPECT_EQ(static_cast<UINT32>(FILE_ATTRIBUTE_NORMAL), attributes);
|
EXPECT_EQ(static_cast<UINT32>(FILE_ATTRIBUTE_NORMAL), attributes);
|
||||||
EXPECT_FALSE(str_descriptor.empty());
|
EXPECT_FALSE(str_descriptor.empty());
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_volume_info_test(remote_client &client) {
|
static void get_volume_info_test(remote_client &client) {
|
||||||
@ -202,7 +202,7 @@ static void mounted_test(remote_client &client) {
|
|||||||
|
|
||||||
static void open_test(remote_client &client) {
|
static void open_test(remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(win_remote_dir, {"open.txt"});
|
const auto test_file = utils::path::combine(win_remote_dir, {"open.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -229,13 +229,13 @@ static void open_test(remote_client &client) {
|
|||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc2));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc2));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void overwrite_test(remote_client &client) {
|
static void overwrite_test(remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(win_remote_dir, {"overwrite.txt"});
|
utils::path::combine(win_remote_dir, {"overwrite.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ static void overwrite_test(remote_client &client) {
|
|||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_and_read_directory_test(remote_client &client) {
|
static void create_and_read_directory_test(remote_client &client) {
|
||||||
@ -329,7 +329,7 @@ static void open_and_read_directory_test(remote_client &client) {
|
|||||||
static void read_and_write_test(remote_client &client) {
|
static void read_and_write_test(remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(win_remote_dir, {"read_and_write.txt"});
|
utils::path::combine(win_remote_dir, {"read_and_write.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -365,14 +365,14 @@ static void read_and_write_test(remote_client &client) {
|
|||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rename_test(remote_client &client) {
|
static void rename_test(remote_client &client) {
|
||||||
const auto test_file = utils::path::combine(win_remote_dir, {"rename.txt"});
|
const auto test_file = utils::path::combine(win_remote_dir, {"rename.txt"});
|
||||||
const auto test_file2 = utils::path::combine(win_remote_dir, {"rename2.txt"});
|
const auto test_file2 = utils::path::combine(win_remote_dir, {"rename2.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file2));
|
EXPECT_TRUE(utils::file::file(test_file2).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
auto api_path2 =
|
auto api_path2 =
|
||||||
@ -394,15 +394,15 @@ static void rename_test(remote_client &client) {
|
|||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file2));
|
EXPECT_TRUE(utils::file::file(test_file2).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_basic_info_test(remote_client &client) {
|
static void set_basic_info_test(remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(win_remote_dir, {"set_basic_info.txt"});
|
utils::path::combine(win_remote_dir, {"set_basic_info.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -447,13 +447,13 @@ static void set_basic_info_test(remote_client &client) {
|
|||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_file_size_test(remote_client &client) {
|
static void set_file_size_test(remote_client &client) {
|
||||||
const auto test_file =
|
const auto test_file =
|
||||||
utils::path::combine(win_remote_dir, {"set_file_size.txt"});
|
utils::path::combine(win_remote_dir, {"set_file_size.txt"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
auto api_path =
|
auto api_path =
|
||||||
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
utils::string::from_utf8(test_file).substr(mount_location_.size());
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ static void set_file_size_test(remote_client &client) {
|
|||||||
|
|
||||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unmounted_test(remote_client &client) {
|
static void unmounted_test(remote_client &client) {
|
||||||
|
@ -113,7 +113,7 @@ static auto create_test(winfsp_test *test, const std::string &mount_point) {
|
|||||||
static void delete_file_test(const std::string &file) {
|
static void delete_file_test(const std::string &file) {
|
||||||
TEST_HEADER(__FUNCTION__);
|
TEST_HEADER(__FUNCTION__);
|
||||||
event_capture ec({"file_removed"});
|
event_capture ec({"file_removed"});
|
||||||
EXPECT_TRUE(utils::file::retry_delete_file(file));
|
EXPECT_TRUE(utils::file::file(file).remove());
|
||||||
EXPECT_FALSE(utils::file::file(file).exists());
|
EXPECT_FALSE(utils::file::file(file).exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ struct result final {
|
|||||||
[[nodiscard]] operator bool() const { return ok; }
|
[[nodiscard]] operator bool() const { return ok; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using retryable_action_t = std::function<bool()>;
|
||||||
|
|
||||||
[[nodiscard]] inline constexpr auto
|
[[nodiscard]] inline constexpr auto
|
||||||
calculate_read_size(std::uint64_t total_size, std::size_t read_size,
|
calculate_read_size(std::uint64_t total_size, std::size_t read_size,
|
||||||
std::uint64_t offset) -> std::size_t {
|
std::uint64_t offset) -> std::size_t {
|
||||||
@ -90,6 +92,11 @@ get_next_available_port(std::uint16_t first_port,
|
|||||||
std::uint16_t &available_port) -> bool;
|
std::uint16_t &available_port) -> bool;
|
||||||
#endif // defined(PROJECT_ENABLE_BOOST)
|
#endif // defined(PROJECT_ENABLE_BOOST)
|
||||||
|
|
||||||
|
[[nodiscard]] auto retry_action(retryable_action_t action,
|
||||||
|
std::size_t retry_count = 200U,
|
||||||
|
std::chrono::milliseconds retry_wait =
|
||||||
|
std::chrono::milliseconds(10)) -> bool;
|
||||||
|
|
||||||
template <typename result_t, typename data_t>
|
template <typename result_t, typename data_t>
|
||||||
inline constexpr auto divide_with_ceiling(result_t numerator,
|
inline constexpr auto divide_with_ceiling(result_t numerator,
|
||||||
data_t denominator) -> result_t {
|
data_t denominator) -> result_t {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "utils/common.hpp"
|
#include "utils/common.hpp"
|
||||||
|
|
||||||
|
#include "utils/error.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
namespace repertory::utils {
|
namespace repertory::utils {
|
||||||
@ -153,4 +154,27 @@ auto get_next_available_port(std::uint16_t first_port,
|
|||||||
return not error_code;
|
return not error_code;
|
||||||
}
|
}
|
||||||
#endif // defined(PROJECT_ENABLE_BOOST)
|
#endif // defined(PROJECT_ENABLE_BOOST)
|
||||||
|
|
||||||
|
auto retry_action(retryable_action_t action, std::size_t retry_count,
|
||||||
|
std::chrono::milliseconds retry_wait) -> bool {
|
||||||
|
static constexpr const std::string_view function_name{
|
||||||
|
static_cast<const char *>(__FUNCTION__),
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (std::size_t idx = 0U; idx < retry_count; ++idx) {
|
||||||
|
if (action()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(retry_wait);
|
||||||
|
}
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
utils::error::handle_exception(function_name, e);
|
||||||
|
} catch (...) {
|
||||||
|
utils::error::handle_exception(function_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} // namespace repertory::utils
|
} // namespace repertory::utils
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
|
#include "utils/common.hpp"
|
||||||
#include "utils/error.hpp"
|
#include "utils/error.hpp"
|
||||||
#include "utils/unix.hpp"
|
#include "utils/unix.hpp"
|
||||||
#include "utils/windows.hpp"
|
#include "utils/windows.hpp"
|
||||||
@ -329,6 +330,7 @@ auto directory::remove() -> bool {
|
|||||||
static_cast<const char *>(__FUNCTION__),
|
static_cast<const char *>(__FUNCTION__),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return utils::retry_action([this]() -> bool {
|
||||||
try {
|
try {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return (not exists() || ::RemoveDirectoryA(path_.c_str()));
|
return (not exists() || ::RemoveDirectoryA(path_.c_str()));
|
||||||
@ -342,6 +344,7 @@ auto directory::remove() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto directory::remove_recursively() -> bool {
|
auto directory::remove_recursively() -> bool {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
|
#include "utils/common.hpp"
|
||||||
#include "utils/encryption.hpp"
|
#include "utils/encryption.hpp"
|
||||||
#include "utils/error.hpp"
|
#include "utils/error.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "utils/path.hpp"
|
||||||
@ -339,12 +340,14 @@ auto file::remove() -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return utils::retry_action([this]() -> bool {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return !!::DeleteFileA(path_.c_str());
|
return !!::DeleteFileA(path_.c_str());
|
||||||
#else // !defined(_WIN32)
|
#else // !defined(_WIN32)
|
||||||
std::error_code ec{};
|
std::error_code ec{};
|
||||||
return std::filesystem::remove(path_, ec);
|
return std::filesystem::remove(path_, ec);
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto file::truncate(std::size_t size) -> bool {
|
auto file::truncate(std::size_t size) -> bool {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
|
#include "utils/common.hpp"
|
||||||
#include "utils/error.hpp"
|
#include "utils/error.hpp"
|
||||||
|
|
||||||
#if defined(PROJECT_ENABLE_LIBDSM)
|
#if defined(PROJECT_ENABLE_LIBDSM)
|
||||||
@ -490,6 +491,8 @@ auto smb_directory::remove() -> bool {
|
|||||||
throw std::runtime_error("session not found|" + path_);
|
throw std::runtime_error("session not found|" + path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return utils::retry_action([this]() -> bool {
|
||||||
|
try {
|
||||||
auto res = smb_directory_rm(session_.get(), tid_,
|
auto res = smb_directory_rm(session_.get(), tid_,
|
||||||
smb_create_relative_path(path_).c_str());
|
smb_create_relative_path(path_).c_str());
|
||||||
if (res != DSM_SUCCESS) {
|
if (res != DSM_SUCCESS) {
|
||||||
@ -504,6 +507,14 @@ auto smb_directory::remove() -> bool {
|
|||||||
utils::error::handle_exception(function_name);
|
utils::error::handle_exception(function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
utils::error::handle_exception(function_name, e);
|
||||||
|
} catch (...) {
|
||||||
|
utils::error::handle_exception(function_name);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
|
#include "utils/common.hpp"
|
||||||
#include "utils/error.hpp"
|
#include "utils/error.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
@ -270,6 +271,7 @@ auto smb_file::remove() -> bool {
|
|||||||
static_cast<const char *>(__FUNCTION__),
|
static_cast<const char *>(__FUNCTION__),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return utils::retry_action([this]() -> bool {
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
|
|
||||||
@ -296,6 +298,7 @@ auto smb_file::remove() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto smb_file::size() const -> std::optional<std::uint64_t> {
|
auto smb_file::size() const -> std::optional<std::uint64_t> {
|
||||||
|
Reference in New Issue
Block a user