refactor
This commit is contained in:
parent
11d2c3c69e
commit
afc13b45f4
@ -1,8 +1,3 @@
|
||||
option(PROJECT_ENABLE_S3 "Enable S3 support" ON)
|
||||
if (PROJECT_ENABLE_S3)
|
||||
add_definitions(-DPROJECT_ENABLE_S3)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-include common.hpp ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}")
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
#ifndef INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
#define INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
|
||||
#include "providers/base_provider.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
@ -138,5 +137,4 @@ public:
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
#endif // PROJECT_ENABLE_S3
|
||||
#endif // INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
#ifndef INCLUDE_TYPES_S3_HPP_
|
||||
#define INCLUDE_TYPES_S3_HPP_
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
|
||||
#include "types/repertory.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
@ -33,10 +33,8 @@ static const option display_config_option = {"-dc", "--display_config"};
|
||||
static const option data_directory_option = {"-dd", "--data_directory"};
|
||||
static const option encrypt_option = {"-en", "--encrypt"};
|
||||
static const option drive_information_option = {"-di", "--drive_information"};
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
static const option name_option = {"-na", "--name"};
|
||||
static const option s3_option = {"-s3", "--s3"};
|
||||
#endif // defined(PROJECT_ENABLE_S3)
|
||||
static const option generate_config_option = {"-gc", "--generate_config"};
|
||||
static const option get_option = {"-get", "--get"};
|
||||
static const option get_directory_items_option = {"-gdi",
|
||||
@ -62,10 +60,8 @@ static const std::vector<option> option_list = {
|
||||
data_directory_option,
|
||||
drive_information_option,
|
||||
encrypt_option,
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
s3_option,
|
||||
name_option,
|
||||
#endif // defined(PROJECT_ENABLE_S3)
|
||||
generate_config_option,
|
||||
get_option,
|
||||
get_directory_items_option,
|
||||
|
@ -56,13 +56,11 @@ auto create_provider(const provider_type &prov,
|
||||
config.get_host_config());
|
||||
return std::make_unique<sia_provider>(config, *comm);
|
||||
}
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
case provider_type::s3: {
|
||||
create_comm<i_http_comm, curl_comm, s3_config>(comm,
|
||||
config.get_s3_config());
|
||||
return std::make_unique<s3_provider>(config, *comm);
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_S3)
|
||||
case provider_type::encrypt: {
|
||||
return std::make_unique<encrypt_provider>(config);
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
|
||||
#include "providers/s3/s3_provider.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
@ -887,5 +885,3 @@ auto s3_provider::upload_file_impl(const std::string &api_path,
|
||||
return api_error::success;
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // PROJECT_ENABLE_S3
|
||||
|
@ -52,11 +52,9 @@ void get_api_authentication_data(std::string &user, std::string &password,
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_provider_type_from_args(std::vector<const char *> args) -> provider_type {
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
if (has_option(args, options::s3_option)) {
|
||||
return provider_type::s3;
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_S3)
|
||||
if (has_option(args, options::remote_mount_option)) {
|
||||
return provider_type::remote;
|
||||
}
|
||||
@ -138,12 +136,9 @@ auto parse_drive_options(
|
||||
if ((std::string(args.at(i)) == options::remote_mount_option.at(0U)) ||
|
||||
(std::string(args.at(i)) == options::remote_mount_option.at(1U)) ||
|
||||
(std::string(args.at(i)) == options::data_directory_option.at(0U)) ||
|
||||
(std::string(args.at(i)) == options::data_directory_option.at(1U))
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
|| (std::string(args.at(i)) == options::name_option.at(0U)) ||
|
||||
(std::string(args.at(i)) == options::name_option.at(1U))
|
||||
#endif // PROJECT_ENABLE_S3
|
||||
) {
|
||||
(std::string(args.at(i)) == options::data_directory_option.at(1U)) ||
|
||||
(std::string(args.at(i)) == options::name_option.at(0U)) ||
|
||||
(std::string(args.at(i)) == options::name_option.at(1U))) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
@ -164,12 +159,10 @@ auto parse_drive_options(
|
||||
|
||||
const auto fuse_option_list = utils::string::split(options, ',');
|
||||
for (const auto &fuse_option : fuse_option_list) {
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
if (fuse_option.find("s3") == 0) {
|
||||
prov = provider_type::s3;
|
||||
continue;
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_S3)
|
||||
if ((fuse_option.find("dd") == 0) ||
|
||||
(fuse_option.find("data_directory") == 0)) {
|
||||
const auto data = utils::string::split(fuse_option, '=');
|
||||
|
@ -36,13 +36,11 @@ template <typename drive> inline void help(std::vector<const char *> args) {
|
||||
std::cout << " -di,--drive_information Display mounted drive "
|
||||
"information"
|
||||
<< std::endl;
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
std::cout << " -s3,--s3 Enables S3 mode"
|
||||
<< std::endl;
|
||||
std::cout << " -na,--name Unique name for S3 "
|
||||
"instance [Required]"
|
||||
<< std::endl;
|
||||
#endif // defined(PROJECT_ENABLE_S3)
|
||||
std::cout
|
||||
<< " -gc,--generate_config Generate initial configuration"
|
||||
<< std::endl;
|
||||
@ -72,11 +70,9 @@ template <typename drive> inline void help(std::vector<const char *> args) {
|
||||
std::cout << " -pw,--password Specify API password"
|
||||
<< std::endl;
|
||||
#if !defined(_WIN32)
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
std::cout << " -o s3 Enables S3 mode for "
|
||||
"'fstab' mounts"
|
||||
<< std::endl;
|
||||
#endif // defined(PROJECT_ENABLE_S3)
|
||||
#endif // _WIN32
|
||||
std::cout << " -set,--set [name] [value] Set configuration value"
|
||||
<< std::endl;
|
||||
|
@ -92,7 +92,6 @@ auto main(int argc, char **argv) -> int {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
if ((res == exit_code::success) && (prov == provider_type::s3)) {
|
||||
std::string data;
|
||||
res = utils::cli::parse_string_option(
|
||||
@ -111,7 +110,6 @@ auto main(int argc, char **argv) -> int {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // PROJECT_ENABLE_S3
|
||||
|
||||
int mount_result{};
|
||||
if (res == exit_code::success) {
|
||||
|
@ -47,7 +47,6 @@ protected:
|
||||
void SetUp() override {
|
||||
if (PROVIDER_INDEX != 0) {
|
||||
if (PROVIDER_INDEX == 1) {
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
EXPECT_TRUE(utils::file::delete_directory_recursively(
|
||||
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
|
||||
|
||||
@ -86,7 +85,6 @@ protected:
|
||||
comm = std::make_unique<curl_comm>(config->get_s3_config());
|
||||
provider = std::make_unique<s3_provider>(*config, *comm);
|
||||
drive = std::make_unique<winfsp_drive>(*config, lock_data_, *provider);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,6 @@ TEST(fuse_drive, all_tests) {
|
||||
|
||||
switch (idx) {
|
||||
case 0U: {
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
config_ptr =
|
||||
std::make_unique<app_config>(provider_type::s3, cfg_directory);
|
||||
{
|
||||
@ -549,9 +548,6 @@ TEST(fuse_drive, all_tests) {
|
||||
comm_ptr = std::make_unique<curl_comm>(config_ptr->get_s3_config());
|
||||
provider_ptr = std::make_unique<s3_provider>(*config_ptr, *comm_ptr);
|
||||
drive_args = std::vector<std::string>({"-s3", "-na", "storj"});
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
} break;
|
||||
|
||||
case 1U: {
|
||||
|
@ -669,7 +669,6 @@ TEST(providers, encrypt_provider) {
|
||||
event_system::instance().stop();
|
||||
}
|
||||
|
||||
#if defined(PROJECT_ENABLE_S3)
|
||||
TEST(providers, s3_provider) {
|
||||
const auto config_path =
|
||||
utils::path::combine(get_test_dir(), {"s3_provider"});
|
||||
@ -707,7 +706,6 @@ TEST(providers, s3_provider) {
|
||||
}
|
||||
event_system::instance().stop();
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(providers, sia_provider) {
|
||||
const auto config_path =
|
||||
|
@ -333,11 +333,9 @@ TEST_F(winfsp_test, all_tests) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined(PROJECT_ENABLE_S3)
|
||||
if (PROVIDER_INDEX == 1U) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string mount_point;
|
||||
const auto drive_args = mount_setup(mount_point);
|
||||
|
Loading…
x
Reference in New Issue
Block a user