26 Commits

Author SHA1 Message Date
8d2024d34b refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 19:34:42 -05:00
4f2ee2ad99 [bug] Directories are not importing properly for Sia #43 2025-04-03 19:27:46 -05:00
533938bcef [bug] Directories are not importing properly for Sia #43 2025-04-03 19:26:42 -05:00
98edf33be4 updated CHANGELOG.md
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 17:23:11 -05:00
a080c9ff86 refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 17:20:03 -05:00
e6cdcd74a1 [bug] Directories are not importing properly for Sia #43
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 14:26:22 -05:00
573ae549be updated CHANGELOG.md
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 13:01:48 -05:00
fca149f998 removed debugging 2025-04-03 12:57:40 -05:00
76e375c488 debugging
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 11:59:28 -05:00
3f9322f659 debugging
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 11:48:22 -05:00
c286d496c3 fix
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-03 11:16:03 -05:00
56ba0fcb83 debugging
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
2025-04-03 11:08:48 -05:00
dcafb104ea [Unit Test] Complete WinFSP unit tests #21
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
initial support for winfsp to linux remote testing
initial support for linx to winfsp remote testing
2025-04-02 14:18:35 -05:00
ab757dfd36 [Unit Test] Complete WinFSP unit tests #21
initial support for winfsp to linux remote testing
2025-04-02 14:11:37 -05:00
eec2d2e9a9 fix and refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-02 14:05:10 -05:00
8c1c91e02b fix
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
2025-04-02 13:58:29 -05:00
bb85015733 [bug] Remote mount directory listing on Windows connected to Linux is failing #42
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
2025-04-02 13:40:15 -05:00
883de836c6 fix missing function name
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-02 11:09:05 -05:00
bf2bdd1b5d [bug] Remote mount directory listing on Windows connected to Linux is failing #42
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-02 10:41:05 -05:00
f1e82d8f9f [bug] Remote mount directory listing on Windows connected to Linux is failing #42
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-04-02 10:21:29 -05:00
f5c4aebdac fix json names 2025-04-02 10:17:23 -05:00
f2f9e8fd15 updated CHANGELOG.md
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-03-27 10:01:18 -05:00
2a673915af updated CHANGELOG.md 2025-03-27 10:00:06 -05:00
df3db38ae7 letters should be lowercase 2025-03-27 09:58:11 -05:00
b0b69c6dd4 refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-03-26 14:33:34 -05:00
11b118a30f updated version 2025-03-26 07:11:35 -05:00
16 changed files with 407 additions and 248 deletions

View File

@ -1,7 +1,23 @@
# Changelog # Changelog
## v2.0.6-release
### Issues
* ~~\#12 [Unit Test] Complete all providers unit tests~~
* ~~\#21 [Unit Test] Complete WinFSP unit tests~~
* ~~\#22 [Unit Test] Complete FUSE unit tests~~
* ~~\#33 Complete initial v2.0 documentation~~
* \#42 [bug] Remote mount directory listing on Windows connected to Linux is failing
* \#43 [bug] Directories are not importing properly for Sia
### Changes from v2.0.5-rc
* Drive letters in UI should always be lowercase
## v2.0.5-rc ## v2.0.5-rc
<!-- markdownlint-disable-next-line -->
### Issues ### Issues
* \#39 Create management portal in Flutter * \#39 Create management portal in Flutter

View File

@ -10,7 +10,7 @@ PROJECT_DESC="Mount utility for Sia and S3"
PROJECT_MAJOR_VERSION=2 PROJECT_MAJOR_VERSION=2
PROJECT_MINOR_VERSION=0 PROJECT_MINOR_VERSION=0
PROJECT_REVISION_VERSION=5 PROJECT_REVISION_VERSION=6
PROJECT_RELEASE_NUM=0 PROJECT_RELEASE_NUM=0
PROJECT_RELEASE_ITER=rc PROJECT_RELEASE_ITER=rc

View File

@ -225,8 +225,7 @@ public:
} }
if (curl_code != CURLE_OK) { if (curl_code != CURLE_OK) {
event_system::instance().raise<curl_error>(curl_code, function_name, event_system::instance().raise<curl_error>(curl_code, function_name, url);
url);
return false; return false;
} }

View File

@ -54,12 +54,13 @@ REPERTORY_IGNORE_WARNINGS_DISABLE()
using namespace std::chrono_literals; using namespace std::chrono_literals;
using json = nlohmann::json; using json = nlohmann::json;
inline constexpr const std::string_view REPERTORY = "repertory"; inline constexpr const std::string_view REPERTORY{"repertory"};
inline constexpr const std::wstring_view REPERTORY_W = L"repertory"; inline constexpr const std::string_view REPERTORY_DATA_NAME{"repertory2"};
inline constexpr const std::wstring_view REPERTORY_W{L"repertory"};
inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION = 2ULL; inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION{2ULL};
inline constexpr const std::string_view REPERTORY_DATA_NAME = "repertory2"; inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION{"2.0.0"};
inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION = "2.0.0"; inline constexpr const std::string_view RENTERD_MIN_VERSION{"2.0.0"};
#define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE #define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE

View File

@ -59,7 +59,8 @@ private:
static void populate_stat(const struct stat64 &unix_st, remote::stat &r_stat); static void populate_stat(const struct stat64 &unix_st, remote::stat &r_stat);
[[nodiscard]] auto update_to_windows_format(json &item) -> json &; [[nodiscard]] auto update_to_windows_format(const std::string &root_api_path,
json &item) -> json &;
public: public:
// FUSE Layer // FUSE Layer

View File

@ -49,6 +49,12 @@ private:
sia_config sia_config_; sia_config sia_config_;
private: private:
[[nodiscard]] auto create_directory_key(const std::string &api_path) const
-> repertory::api_error;
[[nodiscard]] auto ensure_directory_exists(const std::string &api_path) const
-> api_error;
[[nodiscard]] auto get_object_info(const std::string &api_path, [[nodiscard]] auto get_object_info(const std::string &api_path,
json &object_info) const -> api_error; json &object_info) const -> api_error;

View File

@ -374,13 +374,13 @@ auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * {
if (not utils::file::change_to_process_directory()) { if (not utils::file::change_to_process_directory()) {
utils::error::raise_error(function_name, utils::error::raise_error(function_name,
"failed to change to process directory"); "failed to change to process directory");
event_system::instance().raise<unmount_requested>(); event_system::instance().raise<unmount_requested>(function_name);
return this; return this;
} }
if (not console_enabled_ && not repertory::project_initialize()) { if (not console_enabled_ && not repertory::project_initialize()) {
utils::error::raise_error(function_name, "failed to initialize repertory"); utils::error::raise_error(function_name, "failed to initialize repertory");
event_system::instance().raise<unmount_requested>(); event_system::instance().raise<unmount_requested>(function_name);
} }
return this; return this;

View File

@ -259,7 +259,7 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
if (remote_instance_->fuse_init() != 0) { if (remote_instance_->fuse_init() != 0) {
utils::error::raise_error(function_name, utils::error::raise_error(function_name,
"failed to connect to remote server"); "failed to connect to remote server");
event_system::instance().raise<unmount_requested>(); event_system::instance().raise<unmount_requested>(function_name);
} else { } else {
server_ = std::make_shared<server>(config_); server_ = std::make_shared<server>(config_);
server_->start(); server_->start();

View File

@ -1390,11 +1390,11 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
item_list.clear(); item_list.clear();
const auto handle = reinterpret_cast<remote::file_handle>(file_desc); auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = static_cast<packet::error_type>( auto ret = static_cast<packet::error_type>(
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE)); has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE));
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
const auto api_path = construct_api_path( auto api_path = construct_api_path(
get_open_file_path(static_cast<native_handle>(handle))); get_open_file_path(static_cast<native_handle>(handle)));
directory_iterator iterator(drive_.get_directory_items(api_path)); directory_iterator iterator(drive_.get_directory_items(api_path));
auto offset = marker == nullptr auto offset = marker == nullptr
@ -1405,7 +1405,7 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
json item; json item;
while (iterator.get_json(offset++, item) == 0) { while (iterator.get_json(offset++, item) == 0) {
try { try {
item_list.emplace_back(update_to_windows_format(item)); item_list.emplace_back(update_to_windows_format(api_path, item));
} catch (const std::exception &e) { } catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "exception occurred"); utils::error::raise_error(function_name, e, "exception occurred");
} }
@ -1679,30 +1679,53 @@ auto remote_server::json_release_directory_snapshot(
return 0; return 0;
} }
auto remote_server::update_to_windows_format(json &item) -> json & { auto remote_server::update_to_windows_format(const std::string &root_api_path,
const auto api_path = item["path"].get<std::string>(); json &item) -> json & {
item["meta"][META_ACCESSED] = std::to_string( REPERTORY_USES_FUNCTION_NAME();
utils::string::to_uint64(empty_as_zero(item["meta"][META_ACCESSED])));
item["meta"][META_CREATION] = std::to_string(
utils::string::to_uint64(empty_as_zero(item["meta"][META_CREATION])));
item["meta"][META_MODIFIED] = std::to_string(
utils::string::to_uint64(empty_as_zero(item["meta"][META_MODIFIED])));
if (item["meta"][META_WRITTEN].empty() || auto api_path = item[JSON_API_PATH].get<std::string>();
(item["meta"][META_WRITTEN].get<std::string>() == "0") || if (api_path == "." || api_path == "..") {
(item["meta"][META_WRITTEN].get<std::string>() == auto orig_api_path{api_path};
std::to_string(utils::time::WIN32_TIME_CONVERSION))) {
drive_.set_item_meta(api_path, META_WRITTEN, api_path = api_path == "."
item["meta"][META_MODIFIED].get<std::string>()); ? root_api_path
item["meta"][META_WRITTEN] = item["meta"][META_MODIFIED]; : utils::path::get_parent_api_path(root_api_path);
api_meta_map meta;
auto res = drive_.get_item_meta(api_path, meta);
if (res != api_error::success) {
utils::error::raise_api_path_error(
function_name, api_path, res,
fmt::format("failed to get '{}' meta", orig_api_path));
return item;
} }
if (item["meta"][META_ATTRIBUTES].empty()) { item[JSON_META] = meta;
item["meta"][META_ATTRIBUTES] = }
item["directory"].get<bool>() ? std::to_string(FILE_ATTRIBUTE_DIRECTORY)
item[JSON_META][META_ACCESSED] = std::to_string(
utils::string::to_uint64(empty_as_zero(item[JSON_META][META_ACCESSED])));
item[JSON_META][META_CREATION] = std::to_string(
utils::string::to_uint64(empty_as_zero(item[JSON_META][META_CREATION])));
item[JSON_META][META_MODIFIED] = std::to_string(
utils::string::to_uint64(empty_as_zero(item[JSON_META][META_MODIFIED])));
if (item[JSON_META][META_WRITTEN].empty() ||
(item[JSON_META][META_WRITTEN].get<std::string>() == "0") ||
(item[JSON_META][META_WRITTEN].get<std::string>() ==
std::to_string(utils::time::WIN32_TIME_CONVERSION))) {
drive_.set_item_meta(api_path, META_WRITTEN,
item[JSON_META][META_MODIFIED].get<std::string>());
item[JSON_META][META_WRITTEN] = item[JSON_META][META_MODIFIED];
}
if (item[JSON_META][META_ATTRIBUTES].empty()) {
item[JSON_META][META_ATTRIBUTES] =
item[JSON_DIRECTORY].get<bool>()
? std::to_string(FILE_ATTRIBUTE_DIRECTORY)
: std::to_string(FILE_ATTRIBUTE_ARCHIVE); : std::to_string(FILE_ATTRIBUTE_ARCHIVE);
drive_.set_item_meta(api_path, META_ATTRIBUTES, drive_.set_item_meta(api_path, META_ATTRIBUTES,
item["meta"][META_ATTRIBUTES].get<std::string>()); item[JSON_META][META_ATTRIBUTES].get<std::string>());
} }
return item; return item;

View File

@ -361,11 +361,10 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
&ret)) { &ret)) {
auto item_found = false; auto item_found = false;
for (const auto &item : item_list) { for (const auto &item : item_list) {
auto item_path = item["path"].get<std::string>(); auto item_path = item[JSON_API_PATH].get<std::string>();
auto display_name = utils::string::from_utf8( auto display_name = utils::string::from_utf8(
utils::path::strip_to_file_name(item_path)); utils::path::strip_to_file_name(item_path));
if (not marker || (marker && item_found)) { if (not marker || (marker && item_found)) {
// if (not utils::path::is_ads_file_path(item_path)) {
union { union {
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) + UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
((repertory::max_path_length + 1U) * sizeof(WCHAR))]; ((repertory::max_path_length + 1U) * sizeof(WCHAR))];
@ -380,10 +379,8 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
display_name.size()) * display_name.size()) *
sizeof(WCHAR))); sizeof(WCHAR)));
if (not item["meta"].empty() ||
((item_path != ".") && (item_path != ".."))) {
populate_file_info(item, directory_info->FileInfo); populate_file_info(item, directory_info->FileInfo);
}
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
::wcscpy_s(&directory_info->FileNameBuf[0], ::wcscpy_s(&directory_info->FileNameBuf[0],
repertory::max_path_length, &display_name[0]); repertory::max_path_length, &display_name[0]);
@ -394,7 +391,6 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
break; break;
} }
} }
// }
} else { } else {
item_found = display_name == std::wstring(marker); item_found = display_name == std::wstring(marker);
} }

View File

@ -67,7 +67,7 @@ auto sia_provider::check_version(std::string &required_version,
std::string &returned_version) const -> bool { std::string &returned_version) const -> bool {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
required_version = "2.0.0"; required_version = RENTERD_MIN_VERSION;
try { try {
curl::requests::http_get get{}; curl::requests::http_get get{};
@ -149,6 +149,52 @@ auto sia_provider::create_directory_impl(const std::string &api_path,
return api_error::success; return api_error::success;
} }
auto sia_provider::create_directory_key(const std::string &api_path) const
-> api_error {
auto parent_api_path = utils::path::get_parent_api_path(api_path);
json object_list{};
if (not get_object_list(parent_api_path, object_list)) {
return api_error::comm_error;
}
if (not object_list.contains("objects")) {
return api_error::directory_not_found;
}
const auto &list = object_list.at("objects");
if (std::ranges::find_if(list, [&api_path](auto &&entry) -> bool {
return entry.at("key").template get<std::string>() == api_path + '/';
}) == list.end()) {
return api_error::directory_not_found;
}
api_meta_map meta;
return const_cast<sia_provider *>(this)->create_directory_impl(api_path,
meta);
}
auto sia_provider::ensure_directory_exists(const std::string &api_path) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME();
bool exists{};
auto res{is_directory(api_path, exists)};
if (res != api_error::success) {
utils::error::raise_api_path_error(function_name, api_path, res,
"failed detect existing directory");
return res;
}
if (not exists) {
utils::error::raise_api_path_error(function_name, api_path, res,
"directory not found");
return api_error::directory_not_found;
}
return api_error::success;
}
auto sia_provider::get_directory_item_count(const std::string &api_path) const auto sia_provider::get_directory_item_count(const std::string &api_path) const
-> std::uint64_t { -> std::uint64_t {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@ -215,7 +261,18 @@ auto sia_provider::get_directory_items_impl(const std::string &api_path,
directory ? 0U directory ? 0U
: entry["size"].get<std::uint64_t>(), : entry["size"].get<std::uint64_t>(),
get_last_modified(entry)); get_last_modified(entry));
if (directory) {
auto res{ensure_directory_exists(entry_api_path)};
if (res != api_error::success) {
utils::error::raise_api_path_error(
function_name, entry_api_path, res,
"failed detect existing directory");
continue;
}
}
get_api_item_added()(directory, file); get_api_item_added()(directory, file);
auto res{get_item_meta(entry_api_path, meta)}; auto res{get_item_meta(entry_api_path, meta)};
if (res != api_error::success) { if (res != api_error::success) {
utils::error::raise_api_path_error(function_name, entry_api_path, utils::error::raise_api_path_error(function_name, entry_api_path,
@ -320,6 +377,15 @@ auto sia_provider::get_file_list(api_file_list &list,
create_api_file(entry_api_path, "", 0U, create_api_file(entry_api_path, "", 0U,
get_last_modified(entry)), get_last_modified(entry)),
}; };
auto res{ensure_directory_exists(entry_api_path)};
if (res != api_error::success) {
utils::error::raise_api_path_error(
function_name, entry_api_path, res,
"failed detect existing directory");
return res;
}
get_api_item_added()(true, dir); get_api_item_added()(true, dir);
} }
@ -513,6 +579,14 @@ auto sia_provider::is_directory(const std::string &api_path, bool &exists) const
json file_data{}; json file_data{};
auto res{get_object_info(api_path + '/', file_data)}; auto res{get_object_info(api_path + '/', file_data)};
if (res == api_error::item_not_found) { if (res == api_error::item_not_found) {
if (create_directory_key(api_path) == api_error::success) {
exists = true;
return api_error::success;
}
}
if (res == api_error::directory_not_found ||
res == api_error::item_not_found) {
return api_error::success; return api_error::success;
} }
@ -636,7 +710,6 @@ auto sia_provider::read_file_bytes(const std::string &api_path,
++idx) { ++idx) {
long response_code{}; long response_code{};
const auto notify_retry = [&]() { const auto notify_retry = [&]() {
fmt::println("{}", std::string(buffer.begin(), buffer.end()));
if (response_code == 0) { if (response_code == 0) {
utils::error::raise_api_path_error( utils::error::raise_api_path_error(
function_name, api_path, api_error::comm_error, function_name, api_path, api_error::comm_error,

View File

@ -68,7 +68,9 @@ void server::handle_set_config_value_by_name(const httplib::Request &req,
void server::handle_unmount(const httplib::Request & /*req*/, void server::handle_unmount(const httplib::Request & /*req*/,
httplib::Response &res) { httplib::Response &res) {
event_system::instance().raise<unmount_requested>(); REPERTORY_USES_FUNCTION_NAME();
event_system::instance().raise<unmount_requested>(function_name);
res.status = http_error_codes::ok; res.status = http_error_codes::ok;
} }

View File

@ -23,6 +23,8 @@
#include "backward.hpp" #include "backward.hpp"
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP) #endif // defined(PROJECT_ENABLE_BACKWARD_CPP)
#include <algorithm>
#include "cli/actions.hpp" #include "cli/actions.hpp"
#include "initialize.hpp" #include "initialize.hpp"
#include "types/repertory.hpp" #include "types/repertory.hpp"
@ -44,7 +46,7 @@ auto main(int argc, char **argv) -> int {
std::vector<const char *> args; std::vector<const char *> args;
{ {
auto args_span = std::span(argv, static_cast<std::size_t>(argc)); auto args_span = std::span(argv, static_cast<std::size_t>(argc));
std::copy(args_span.begin(), args_span.end(), std::back_inserter(args)); std::ranges::copy(args_span, std::back_inserter(args));
} }
if (argc == 1) { if (argc == 1) {

View File

@ -326,9 +326,9 @@ void handlers::handle_put_mount_location(const httplib::Request &req,
void handlers::handle_get_available_locations(httplib::Response &res) { void handlers::handle_get_available_locations(httplib::Response &res) {
#if defined(_WIN32) #if defined(_WIN32)
constexpr const std::array<std::string_view, 26U> letters{ constexpr const std::array<std::string_view, 26U> letters{
"A:", "B:", "C:", "D:", "E:", "F:", "G:", "H:", "I:", "a:", "b:", "c:", "d:", "e:", "f:", "g:", "h:", "i:",
"J:", "K:", "L:", "M:", "N:", "O:", "P:", "Q:", "R:", "j:", "k:", "l:", "m:", "n:", "o:", "p:", "q:", "r:",
"S:", "T:", "U:", "V:", "W:", "X:", "Y:", "Z:", "s:", "t:", "u:", "v:", "w:", "x:", "y:", "z:",
}; };
auto available = std::accumulate( auto available = std::accumulate(

View File

@ -54,21 +54,31 @@ namespace repertory {
struct local_s3 final { struct local_s3 final {
static constexpr const provider_type type{provider_type::s3}; static constexpr const provider_type type{provider_type::s3};
static constexpr const provider_type type2{provider_type::s3}; static constexpr const provider_type type2{provider_type::s3};
static constexpr const std::uint16_t port{0U};
}; };
struct local_sia final { struct local_sia final {
static constexpr const provider_type type{provider_type::sia}; static constexpr const provider_type type{provider_type::sia};
static constexpr const provider_type type2{provider_type::sia}; static constexpr const provider_type type2{provider_type::sia};
static constexpr const std::uint16_t port{0U};
}; };
struct remote_s3 final { struct remote_s3 final {
static constexpr const provider_type type{provider_type::remote}; static constexpr const provider_type type{provider_type::remote};
static constexpr const provider_type type2{provider_type::s3}; static constexpr const provider_type type2{provider_type::s3};
static constexpr const std::uint16_t port{0U};
}; };
struct remote_sia final { struct remote_sia final {
static constexpr const provider_type type{provider_type::remote}; static constexpr const provider_type type{provider_type::remote};
static constexpr const provider_type type2{provider_type::sia}; static constexpr const provider_type type2{provider_type::sia};
static constexpr const std::uint16_t port{0U};
};
struct remote_linux_to_winfsp final {
static constexpr const provider_type type{provider_type::remote};
static constexpr const provider_type type2{provider_type::unknown};
static constexpr const std::uint16_t port{40001U};
}; };
template <typename provider_t> class fuse_test : public ::testing::Test { template <typename provider_t> class fuse_test : public ::testing::Test {
@ -113,7 +123,7 @@ protected:
auto r_cfg = config->get_remote_mount(); auto r_cfg = config->get_remote_mount();
r_cfg.enable = true; r_cfg.enable = true;
r_cfg.api_port = 30000U; r_cfg.api_port = 40000U;
config->set_remote_mount(r_cfg); config->set_remote_mount(r_cfg);
} }
@ -160,7 +170,7 @@ protected:
auto r_cfg = config->get_remote_mount(); auto r_cfg = config->get_remote_mount();
r_cfg.enable = true; r_cfg.enable = true;
r_cfg.api_port = 30000U; r_cfg.api_port = 40000U;
config->set_remote_mount(r_cfg); config->set_remote_mount(r_cfg);
} }
@ -178,7 +188,7 @@ protected:
execute_mount(drive_args, mount_location); execute_mount(drive_args, mount_location);
}; };
const auto mount_remote = [&]() { const auto mount_remote = [&](std::uint16_t port = 40000U) {
{ {
mount_location2 = mount_location; mount_location2 = mount_location;
@ -187,7 +197,8 @@ protected:
{ {
"fuse_test", "fuse_test",
app_config::get_provider_name(provider_t::type) + '_' + app_config::get_provider_name(provider_t::type) + '_' +
app_config::get_provider_name(provider_t::type2), app_config::get_provider_name(provider_t::type2) + '_' +
std::to_string(port),
}); });
mount_location = utils::path::combine(test_directory, {"mount"}); mount_location = utils::path::combine(test_directory, {"mount"});
@ -206,7 +217,7 @@ protected:
"-dd", "-dd",
config2->get_data_directory(), config2->get_data_directory(),
"-rm", "-rm",
"localhost:30000", fmt::format("localhost:{}", port),
mount_location, mount_location,
}); });
} }
@ -233,6 +244,10 @@ protected:
mount_sia(); mount_sia();
} break; } break;
case provider_type::unknown:
mount_remote(provider_t::port);
return;
default: default:
throw std::runtime_error("remote provider type is not implemented"); throw std::runtime_error("remote provider type is not implemented");
return; return;
@ -410,9 +425,15 @@ std::string fuse_test<provider_t>::mount_location;
template <typename provider_t> template <typename provider_t>
std::string fuse_test<provider_t>::mount_location2; std::string fuse_test<provider_t>::mount_location2;
// using fuse_provider_types = ::testing::Types<local_s3, remote_s3>; #if defined(__linux__)
using fuse_provider_types = using fuse_provider_types =
::testing::Types<local_s3, remote_s3, local_sia, remote_sia>; ::testing::Types<local_s3, remote_s3, local_sia, remote_sia>;
// using fuse_provider_types =
// ::testing::Types<local_s3, remote_s3, local_sia, remote_sia,
// remote_linux_to_winfsp>;
#else // !defined(__linux__)
build fails here
#endif // defined(_WIN32)
} // namespace repertory } // namespace repertory
#endif // !defined(_WIN32) #endif // !defined(_WIN32)

View File

@ -45,21 +45,31 @@ namespace repertory {
struct local_s3 final { struct local_s3 final {
static constexpr const provider_type type{provider_type::s3}; static constexpr const provider_type type{provider_type::s3};
static constexpr const provider_type type2{provider_type::s3}; static constexpr const provider_type type2{provider_type::s3};
static constexpr const std::uint16_t port{0U};
}; };
struct local_sia final { struct local_sia final {
static constexpr const provider_type type{provider_type::sia}; static constexpr const provider_type type{provider_type::sia};
static constexpr const provider_type type2{provider_type::sia}; static constexpr const provider_type type2{provider_type::sia};
static constexpr const std::uint16_t port{0U};
}; };
struct remote_s3 final { struct remote_s3 final {
static constexpr const provider_type type{provider_type::remote}; static constexpr const provider_type type{provider_type::remote};
static constexpr const provider_type type2{provider_type::s3}; static constexpr const provider_type type2{provider_type::s3};
static constexpr const std::uint16_t port{0U};
}; };
struct remote_sia final { struct remote_sia final {
static constexpr const provider_type type{provider_type::remote}; static constexpr const provider_type type{provider_type::remote};
static constexpr const provider_type type2{provider_type::sia}; static constexpr const provider_type type2{provider_type::sia};
static constexpr const std::uint16_t port{0U};
};
struct remote_winfsp_to_linux final {
static constexpr const provider_type type{provider_type::remote};
static constexpr const provider_type type2{provider_type::unknown};
static constexpr const std::uint16_t port{40001U};
}; };
template <typename provider_t> class winfsp_test : public ::testing::Test { template <typename provider_t> class winfsp_test : public ::testing::Test {
@ -102,7 +112,7 @@ protected:
auto r_cfg = config->get_remote_mount(); auto r_cfg = config->get_remote_mount();
r_cfg.enable = true; r_cfg.enable = true;
r_cfg.api_port = 30000U; r_cfg.api_port = 40000U;
config->set_remote_mount(r_cfg); config->set_remote_mount(r_cfg);
} }
@ -144,7 +154,7 @@ protected:
auto r_cfg = config->get_remote_mount(); auto r_cfg = config->get_remote_mount();
r_cfg.enable = true; r_cfg.enable = true;
r_cfg.api_port = 30000U; r_cfg.api_port = 40000U;
config->set_remote_mount(r_cfg); config->set_remote_mount(r_cfg);
} }
@ -160,13 +170,15 @@ protected:
execute_mount(drive_args, mount_location); execute_mount(drive_args, mount_location);
}; };
const auto mount_remote = [&]() { const auto mount_remote = [&](std::uint16_t port = 40000U) {
{ {
auto test_directory = utils::path::combine( auto test_directory = utils::path::combine(
test::get_test_output_dir(), test::get_test_output_dir(),
{ {
"winfsp_test", "winfsp_test",
app_config::get_provider_name(provider_type::remote), app_config::get_provider_name(provider_t::type) + '_' +
app_config::get_provider_name(provider_t::type2) + '_' +
std::to_string(port),
}); });
mount_location2 = mount_location; mount_location2 = mount_location;
@ -184,7 +196,7 @@ protected:
"-dd", "-dd",
config->get_data_directory(), config->get_data_directory(),
"-rm", "-rm",
"localhost:30000", fmt::format("localhost:{}", port),
mount_location, mount_location,
}); });
} }
@ -211,6 +223,10 @@ protected:
mount_sia(); mount_sia();
} break; } break;
case provider_type::unknown:
mount_remote(provider_t::port);
return;
default: default:
throw std::runtime_error("remote provider type is not implemented"); throw std::runtime_error("remote provider type is not implemented");
return; return;
@ -228,7 +244,9 @@ protected:
static void TearDownTestCase() { static void TearDownTestCase() {
if (provider_t::type == provider_type::remote) { if (provider_t::type == provider_type::remote) {
execute_unmount(drive_args2, mount_location); execute_unmount(drive_args2, mount_location);
if (provider_t::type2 != provider_type::unknown) {
execute_unmount(drive_args, mount_location2); execute_unmount(drive_args, mount_location2);
}
} else { } else {
execute_unmount(drive_args, mount_location); execute_unmount(drive_args, mount_location);
} }
@ -282,7 +300,8 @@ std::string winfsp_test<provider_t>::mount_location2;
// using winfsp_provider_types = ::testing::Types<local_s3, remote_s3, // using winfsp_provider_types = ::testing::Types<local_s3, remote_s3,
// local_sia, remote_sia>; // local_sia, remote_sia>;
using winfsp_provider_types = ::testing::Types<local_s3, remote_s3>; // using winfsp_provider_types = ::testing::Types<local_s3, remote_s3>;
using winfsp_provider_types = ::testing::Types<remote_winfsp_to_linux>;
} // namespace repertory } // namespace repertory
#endif // defined(_WIN32) #endif // defined(_WIN32)