const refactor

This commit is contained in:
2024-07-17 13:53:56 -05:00
parent 26fa85e421
commit c7318b0383
21 changed files with 132 additions and 142 deletions

View File

@ -101,7 +101,7 @@ private:
std::string cache_directory_;
host_config hc_;
s3_config s3_config_;
std::uint64_t version_ = REPERTORY_CONFIG_VERSION;
std::uint64_t version_{REPERTORY_CONFIG_VERSION};
std::string log_directory_;
mutable std::recursive_mutex read_write_mutex_;
mutable std::recursive_mutex remote_mount_mutex_;

View File

@ -160,11 +160,12 @@ REPERTORY_IGNORE_WARNINGS_DISABLE()
using namespace std::chrono_literals;
using json = nlohmann::json;
#define REPERTORY "repertory"
#define REPERTORY_CONFIG_VERSION 0ull
#define REPERTORY_DATA_NAME "repertory2"
#define REPERTORY_MIN_REMOTE_VERSION "2.0.0"
#define REPERTORY_W L"repertory"
inline constexpr const std::string_view REPERTORY = "repertory";
inline constexpr const std::wstring_view REPERTORY_W = L"repertory";
inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION = 0ULL;
inline constexpr const std::string_view REPERTORY_DATA_NAME = REPERTORY "2";
inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION = "2.0.0";
#if defined(_WIN32)
#define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE
@ -176,7 +177,7 @@ using native_handle = HANDLE;
using native_handle = int;
#endif
constexpr const auto NANOS_PER_SECOND = 1000000000L;
inline constexpr const auto NANOS_PER_SECOND = 1000000000L;
#if defined(_WIN32)
#if defined(CreateDirectory)

View File

@ -21,7 +21,7 @@
*/
#ifndef INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
#define INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_
#if defined(REPERTORY_ENABLE_S3)
#if defined(PROJECT_ENABLE_S3)
#include "providers/base_provider.hpp"
#include "types/repertory.hpp"
@ -45,64 +45,62 @@ public:
auto operator=(s3_provider &&) -> s3_provider & = delete;
private:
[[nodiscard]] auto add_if_not_found(api_file &file,
const std::string &object_name) const
-> api_error;
[[nodiscard]] auto
add_if_not_found(api_file &file,
const std::string &object_name) const -> api_error;
[[nodiscard]] auto create_file_extra(const std::string &api_path,
api_meta_map &meta)
-> api_error override;
[[nodiscard]] auto
create_file_extra(const std::string &api_path,
api_meta_map &meta) -> api_error override;
[[nodiscard]] auto create_path_directories(const std::string &api_path,
const std::string &key) const
-> api_error;
[[nodiscard]] auto
create_path_directories(const std::string &api_path,
const std::string &key) const -> api_error;
[[nodiscard]] auto decrypt_object_name(std::string &object_name) const
-> api_error;
[[nodiscard]] auto
decrypt_object_name(std::string &object_name) const -> api_error;
[[nodiscard]] auto
get_object_info(bool directory, const std::string &api_path,
bool &is_encrypted, std::string &object_name,
head_object_result &result) const -> api_error;
[[nodiscard]] auto
get_object_list(std::string &response_data, long &response_code,
std::optional<std::string> delimiter = std::nullopt,
std::optional<std::string> prefix = std::nullopt) const
-> bool;
[[nodiscard]] auto get_object_list(
std::string &response_data, long &response_code,
std::optional<std::string> delimiter = std::nullopt,
std::optional<std::string> prefix = std::nullopt) const -> bool;
protected:
[[nodiscard]] auto create_directory_impl(const std::string &api_path,
api_meta_map &meta)
-> api_error override;
[[nodiscard]] auto
create_directory_impl(const std::string &api_path,
api_meta_map &meta) -> api_error override;
[[nodiscard]] auto get_directory_items_impl(const std::string &api_path,
directory_item_list &list) const
-> api_error override;
[[nodiscard]] auto get_used_drive_space_impl() const
-> std::uint64_t override;
[[nodiscard]] auto
get_used_drive_space_impl() const -> std::uint64_t override;
[[nodiscard]] auto remove_directory_impl(const std::string &api_path)
-> api_error override;
[[nodiscard]] auto
remove_directory_impl(const std::string &api_path) -> api_error override;
[[nodiscard]] auto remove_file_impl(const std::string &api_path)
-> api_error override;
[[nodiscard]] auto
remove_file_impl(const std::string &api_path) -> api_error override;
[[nodiscard]] auto upload_file_impl(const std::string &api_path,
const std::string &source_path,
stop_type &stop_requested)
-> api_error override;
[[nodiscard]] auto
upload_file_impl(const std::string &api_path, const std::string &source_path,
stop_type &stop_requested) -> api_error override;
public:
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const
-> std::uint64_t override;
[[nodiscard]] auto get_file(const std::string &api_path, api_file &file) const
-> api_error override;
[[nodiscard]] auto get_file(const std::string &api_path,
api_file &file) const -> api_error override;
[[nodiscard]] auto get_file_list(api_file_list &list) const
-> api_error override;
[[nodiscard]] auto
get_file_list(api_file_list &list) const -> api_error override;
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override;
@ -115,8 +113,8 @@ public:
[[nodiscard]] auto is_directory(const std::string &api_path,
bool &exists) const -> api_error override;
[[nodiscard]] auto is_file(const std::string &api_path, bool &exists) const
-> api_error override;
[[nodiscard]] auto is_file(const std::string &api_path,
bool &exists) const -> api_error override;
[[nodiscard]] auto is_online() const -> bool override;
@ -124,15 +122,14 @@ public:
return false;
};
[[nodiscard]] auto read_file_bytes(const std::string &api_path,
std::size_t size, std::uint64_t offset,
data_buffer &data,
stop_type &stop_requested)
-> api_error override;
[[nodiscard]] auto
read_file_bytes(const std::string &api_path, std::size_t size,
std::uint64_t offset, data_buffer &data,
stop_type &stop_requested) -> api_error override;
[[nodiscard]] auto rename_file(const std::string &from_api_path,
const std::string &to_api_path)
-> api_error override;
[[nodiscard]] auto
rename_file(const std::string &from_api_path,
const std::string &to_api_path) -> api_error override;
[[nodiscard]] auto start(api_item_added_callback api_item_added,
i_file_manager *mgr) -> bool override;
@ -141,5 +138,5 @@ public:
};
} // namespace repertory
#endif // REPERTORY_ENABLE_S3
#endif // PROJECT_ENABLE_S3
#endif // INCLUDE_PROVIDERS_S3_S3_PROVIDER_HPP_

View File

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

View File

@ -33,10 +33,10 @@ 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(REPERTORY_ENABLE_S3)
#if defined(PROJECT_ENABLE_S3)
static const option name_option = {"-na", "--name"};
static const option s3_option = {"-s3", "--s3"};
#endif // defined(REPERTORY_ENABLE_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 +62,10 @@ static const std::vector<option> option_list = {
data_directory_option,
drive_information_option,
encrypt_option,
#if defined(REPERTORY_ENABLE_S3)
#if defined(PROJECT_ENABLE_S3)
s3_option,
name_option,
#endif // defined(REPERTORY_ENABLE_S3)
#endif // defined(PROJECT_ENABLE_S3)
generate_config_option,
get_option,
get_directory_items_option,
@ -91,27 +91,26 @@ void get_api_authentication_data(std::string &user, std::string &password,
std::uint16_t &port, const provider_type &prov,
const std::string &data_directory);
[[nodiscard]] auto get_provider_type_from_args(std::vector<const char *> args)
-> provider_type;
[[nodiscard]] auto
get_provider_type_from_args(std::vector<const char *> args) -> provider_type;
[[nodiscard]] auto has_option(std::vector<const char *> args,
const std::string &option_name) -> bool;
[[nodiscard]] auto has_option(std::vector<const char *> args, const option &opt)
-> bool;
[[nodiscard]] auto has_option(std::vector<const char *> args,
const option &opt) -> bool;
[[nodiscard]] auto parse_option(std::vector<const char *> args,
const std::string &option_name,
std::uint8_t count) -> std::vector<std::string>;
[[nodiscard]] auto parse_string_option(std::vector<const char *> args,
const option &opt, std::string &value)
-> exit_code;
const option &opt,
std::string &value) -> exit_code;
[[nodiscard]] auto parse_drive_options(std::vector<const char *> args,
provider_type &prov,
std::string &data_directory)
-> std::vector<std::string>;
[[nodiscard]] auto
parse_drive_options(std::vector<const char *> args, provider_type &prov,
std::string &data_directory) -> std::vector<std::string>;
} // namespace repertory::utils::cli
#endif // INCLUDE_UTILS_CLI_UTILS_HPP_