This commit is contained in:
Scott E. Graves 2024-07-25 10:16:17 -05:00
parent 11d2c3c69e
commit afc13b45f4
13 changed files with 3 additions and 44 deletions

View File

@ -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}") set(CMAKE_CXX_FLAGS "-include common.hpp ${CMAKE_CXX_FLAGS}")
add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}") add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}")

View File

@ -21,7 +21,6 @@
*/ */
#ifndef INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_ #ifndef INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
#define INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_ #define INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
#if defined(PROJECT_ENABLE_S3)
#include "providers/base_provider.hpp" #include "providers/base_provider.hpp"
#include "types/repertory.hpp" #include "types/repertory.hpp"
@ -138,5 +137,4 @@ public:
}; };
} // namespace repertory } // namespace repertory
#endif // PROJECT_ENABLE_S3
#endif // INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_ #endif // INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_

View File

@ -21,7 +21,6 @@
*/ */
#ifndef INCLUDE_TYPES_S3_HPP_ #ifndef INCLUDE_TYPES_S3_HPP_
#define INCLUDE_TYPES_S3_HPP_ #define INCLUDE_TYPES_S3_HPP_
#if defined(PROJECT_ENABLE_S3)
#include "types/repertory.hpp" #include "types/repertory.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"

View File

@ -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 data_directory_option = {"-dd", "--data_directory"};
static const option encrypt_option = {"-en", "--encrypt"}; static const option encrypt_option = {"-en", "--encrypt"};
static const option drive_information_option = {"-di", "--drive_information"}; static const option drive_information_option = {"-di", "--drive_information"};
#if defined(PROJECT_ENABLE_S3)
static const option name_option = {"-na", "--name"}; static const option name_option = {"-na", "--name"};
static const option s3_option = {"-s3", "--s3"}; static const option s3_option = {"-s3", "--s3"};
#endif // defined(PROJECT_ENABLE_S3)
static const option generate_config_option = {"-gc", "--generate_config"}; static const option generate_config_option = {"-gc", "--generate_config"};
static const option get_option = {"-get", "--get"}; static const option get_option = {"-get", "--get"};
static const option get_directory_items_option = {"-gdi", static const option get_directory_items_option = {"-gdi",
@ -62,10 +60,8 @@ static const std::vector<option> option_list = {
data_directory_option, data_directory_option,
drive_information_option, drive_information_option,
encrypt_option, encrypt_option,
#if defined(PROJECT_ENABLE_S3)
s3_option, s3_option,
name_option, name_option,
#endif // defined(PROJECT_ENABLE_S3)
generate_config_option, generate_config_option,
get_option, get_option,
get_directory_items_option, get_directory_items_option,

View File

@ -56,13 +56,11 @@ auto create_provider(const provider_type &prov,
config.get_host_config()); config.get_host_config());
return std::make_unique<sia_provider>(config, *comm); return std::make_unique<sia_provider>(config, *comm);
} }
#if defined(PROJECT_ENABLE_S3)
case provider_type::s3: { case provider_type::s3: {
create_comm<i_http_comm, curl_comm, s3_config>(comm, create_comm<i_http_comm, curl_comm, s3_config>(comm,
config.get_s3_config()); config.get_s3_config());
return std::make_unique<s3_provider>(config, *comm); return std::make_unique<s3_provider>(config, *comm);
} }
#endif // defined(PROJECT_ENABLE_S3)
case provider_type::encrypt: { case provider_type::encrypt: {
return std::make_unique<encrypt_provider>(config); return std::make_unique<encrypt_provider>(config);
} }

View File

@ -19,8 +19,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#if defined(PROJECT_ENABLE_S3)
#include "providers/s3/s3_provider.hpp" #include "providers/s3/s3_provider.hpp"
#include "app_config.hpp" #include "app_config.hpp"
@ -887,5 +885,3 @@ auto s3_provider::upload_file_impl(const std::string &api_path,
return api_error::success; return api_error::success;
} }
} // namespace repertory } // namespace repertory
#endif // PROJECT_ENABLE_S3

View File

@ -52,11 +52,9 @@ void get_api_authentication_data(std::string &user, std::string &password,
[[nodiscard]] auto [[nodiscard]] auto
get_provider_type_from_args(std::vector<const char *> args) -> provider_type { get_provider_type_from_args(std::vector<const char *> args) -> provider_type {
#if defined(PROJECT_ENABLE_S3)
if (has_option(args, options::s3_option)) { if (has_option(args, options::s3_option)) {
return provider_type::s3; return provider_type::s3;
} }
#endif // defined(PROJECT_ENABLE_S3)
if (has_option(args, options::remote_mount_option)) { if (has_option(args, options::remote_mount_option)) {
return provider_type::remote; return provider_type::remote;
} }
@ -138,12 +136,9 @@ auto parse_drive_options(
if ((std::string(args.at(i)) == options::remote_mount_option.at(0U)) || 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::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(0U)) ||
(std::string(args.at(i)) == options::data_directory_option.at(1U)) (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(0U)) || (std::string(args.at(i)) == options::name_option.at(1U))) {
(std::string(args.at(i)) == options::name_option.at(1U))
#endif // PROJECT_ENABLE_S3
) {
i++; i++;
continue; continue;
} }
@ -164,12 +159,10 @@ auto parse_drive_options(
const auto fuse_option_list = utils::string::split(options, ','); const auto fuse_option_list = utils::string::split(options, ',');
for (const auto &fuse_option : fuse_option_list) { for (const auto &fuse_option : fuse_option_list) {
#if defined(PROJECT_ENABLE_S3)
if (fuse_option.find("s3") == 0) { if (fuse_option.find("s3") == 0) {
prov = provider_type::s3; prov = provider_type::s3;
continue; continue;
} }
#endif // defined(PROJECT_ENABLE_S3)
if ((fuse_option.find("dd") == 0) || if ((fuse_option.find("dd") == 0) ||
(fuse_option.find("data_directory") == 0)) { (fuse_option.find("data_directory") == 0)) {
const auto data = utils::string::split(fuse_option, '='); const auto data = utils::string::split(fuse_option, '=');

View File

@ -36,13 +36,11 @@ template <typename drive> inline void help(std::vector<const char *> args) {
std::cout << " -di,--drive_information Display mounted drive " std::cout << " -di,--drive_information Display mounted drive "
"information" "information"
<< std::endl; << std::endl;
#if defined(PROJECT_ENABLE_S3)
std::cout << " -s3,--s3 Enables S3 mode" std::cout << " -s3,--s3 Enables S3 mode"
<< std::endl; << std::endl;
std::cout << " -na,--name Unique name for S3 " std::cout << " -na,--name Unique name for S3 "
"instance [Required]" "instance [Required]"
<< std::endl; << std::endl;
#endif // defined(PROJECT_ENABLE_S3)
std::cout std::cout
<< " -gc,--generate_config Generate initial configuration" << " -gc,--generate_config Generate initial configuration"
<< std::endl; << 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::cout << " -pw,--password Specify API password"
<< std::endl; << std::endl;
#if !defined(_WIN32) #if !defined(_WIN32)
#if defined(PROJECT_ENABLE_S3)
std::cout << " -o s3 Enables S3 mode for " std::cout << " -o s3 Enables S3 mode for "
"'fstab' mounts" "'fstab' mounts"
<< std::endl; << std::endl;
#endif // defined(PROJECT_ENABLE_S3)
#endif // _WIN32 #endif // _WIN32
std::cout << " -set,--set [name] [value] Set configuration value" std::cout << " -set,--set [name] [value] Set configuration value"
<< std::endl; << std::endl;

View File

@ -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)) { if ((res == exit_code::success) && (prov == provider_type::s3)) {
std::string data; std::string data;
res = utils::cli::parse_string_option( res = utils::cli::parse_string_option(
@ -111,7 +110,6 @@ auto main(int argc, char **argv) -> int {
} }
} }
} }
#endif // PROJECT_ENABLE_S3
int mount_result{}; int mount_result{};
if (res == exit_code::success) { if (res == exit_code::success) {

View File

@ -47,7 +47,6 @@ protected:
void SetUp() override { void SetUp() override {
if (PROVIDER_INDEX != 0) { if (PROVIDER_INDEX != 0) {
if (PROVIDER_INDEX == 1) { if (PROVIDER_INDEX == 1) {
#if defined(PROJECT_ENABLE_S3)
EXPECT_TRUE(utils::file::delete_directory_recursively( EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX))); "./winfsp_test" + std::to_string(PROVIDER_INDEX)));
@ -86,7 +85,6 @@ protected:
comm = std::make_unique<curl_comm>(config->get_s3_config()); comm = std::make_unique<curl_comm>(config->get_s3_config());
provider = std::make_unique<s3_provider>(*config, *comm); provider = std::make_unique<s3_provider>(*config, *comm);
drive = std::make_unique<winfsp_drive>(*config, lock_data_, *provider); drive = std::make_unique<winfsp_drive>(*config, lock_data_, *provider);
#endif
return; return;
} }

View File

@ -535,7 +535,6 @@ TEST(fuse_drive, all_tests) {
switch (idx) { switch (idx) {
case 0U: { case 0U: {
#if defined(PROJECT_ENABLE_S3)
config_ptr = config_ptr =
std::make_unique<app_config>(provider_type::s3, cfg_directory); 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()); comm_ptr = std::make_unique<curl_comm>(config_ptr->get_s3_config());
provider_ptr = std::make_unique<s3_provider>(*config_ptr, *comm_ptr); provider_ptr = std::make_unique<s3_provider>(*config_ptr, *comm_ptr);
drive_args = std::vector<std::string>({"-s3", "-na", "storj"}); drive_args = std::vector<std::string>({"-s3", "-na", "storj"});
#else
continue;
#endif
} break; } break;
case 1U: { case 1U: {

View File

@ -669,7 +669,6 @@ TEST(providers, encrypt_provider) {
event_system::instance().stop(); event_system::instance().stop();
} }
#if defined(PROJECT_ENABLE_S3)
TEST(providers, s3_provider) { TEST(providers, s3_provider) {
const auto config_path = const auto config_path =
utils::path::combine(get_test_dir(), {"s3_provider"}); utils::path::combine(get_test_dir(), {"s3_provider"});
@ -707,7 +706,6 @@ TEST(providers, s3_provider) {
} }
event_system::instance().stop(); event_system::instance().stop();
} }
#endif
TEST(providers, sia_provider) { TEST(providers, sia_provider) {
const auto config_path = const auto config_path =

View File

@ -333,11 +333,9 @@ TEST_F(winfsp_test, all_tests) {
return; return;
} }
#if !defined(PROJECT_ENABLE_S3)
if (PROVIDER_INDEX == 1U) { if (PROVIDER_INDEX == 1U) {
return; return;
} }
#endif
std::string mount_point; std::string mount_point;
const auto drive_args = mount_setup(mount_point); const auto drive_args = mount_setup(mount_point);