This commit is contained in:
Scott E. Graves 2024-12-02 13:57:25 -06:00
parent 04f50f7453
commit 429751e1fc

View File

@ -86,8 +86,8 @@ auto s3_provider::create_directory_impl(const std::string &api_path,
api_meta_map &meta) -> api_error { api_meta_map &meta) -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
stop_type stop_requested{false}; stop_type stop_requested{false};
if (is_encrypted) { if (is_encrypted) {
@ -110,7 +110,7 @@ auto s3_provider::create_directory_impl(const std::string &api_path,
{utils::collection::to_hex_string(result)})); {utils::collection::to_hex_string(result)}));
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path); utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path);
curl::requests::http_put_file put_file{}; curl::requests::http_put_file put_file{};
@ -169,11 +169,11 @@ auto s3_provider::create_path_directories(const std::string &api_path,
return api_error::success; return api_error::success;
} }
const auto encryption_token = get_config().get_s3_config().encryption_token; auto encryption_token = get_config().get_s3_config().encryption_token;
const auto is_encrypted = not encryption_token.empty(); auto is_encrypted = not encryption_token.empty();
const auto path_parts = utils::string::split(api_path, '/', false); auto path_parts = utils::string::split(api_path, '/', false);
const auto key_parts = utils::string::split(key, '/', false); auto key_parts = utils::string::split(key, '/', false);
if (is_encrypted && key_parts.size() != path_parts.size()) { if (is_encrypted && key_parts.size() != path_parts.size()) {
return api_error::error; return api_error::error;
@ -225,8 +225,8 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
try { try {
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
auto res = get_item_meta(api_path, META_KEY, key); auto res = get_item_meta(api_path, META_KEY, key);
@ -235,7 +235,7 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
} }
} }
const auto object_name = auto object_name =
api_path == "/" api_path == "/"
? "" ? ""
: utils::path::create_api_path(is_encrypted ? key : api_path); : utils::path::create_api_path(is_encrypted ? key : api_path);
@ -302,8 +302,8 @@ auto s3_provider::get_directory_items_impl(const std::string &api_path,
-> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
auto ret = api_error::success; auto ret = api_error::success;
std::string key; std::string key;
@ -314,7 +314,7 @@ auto s3_provider::get_directory_items_impl(const std::string &api_path,
} }
} }
const auto object_name = auto object_name =
api_path == "/" api_path == "/"
? "" ? ""
: utils::path::create_api_path(is_encrypted ? key : api_path); : utils::path::create_api_path(is_encrypted ? key : api_path);
@ -580,7 +580,7 @@ auto s3_provider::get_object_info(bool directory, const std::string &api_path,
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
try { try {
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
is_encrypted = not cfg.encryption_token.empty(); is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
@ -729,8 +729,8 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
try { try {
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
auto res = get_item_meta(api_path, META_KEY, key); auto res = get_item_meta(api_path, META_KEY, key);
@ -739,7 +739,7 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
const auto read_bytes = const auto read_bytes =
@ -809,7 +809,7 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
return res; return res;
} }
const auto total_size = utils::string::to_uint64(temp); auto total_size = utils::string::to_uint64(temp);
return utils::encryption::read_encrypted_range( return utils::encryption::read_encrypted_range(
{offset, offset + size - 1U}, {offset, offset + size - 1U},
utils::encryption::generate_key<utils::encryption::hash_256_t>( utils::encryption::generate_key<utils::encryption::hash_256_t>(
@ -835,8 +835,8 @@ auto s3_provider::remove_directory_impl(const std::string &api_path)
-> api_error { -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
@ -846,7 +846,7 @@ auto s3_provider::remove_directory_impl(const std::string &api_path)
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
curl::requests::http_delete del{}; curl::requests::http_delete del{};
@ -877,8 +877,8 @@ auto s3_provider::remove_directory_impl(const std::string &api_path)
auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error { auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
@ -888,7 +888,7 @@ auto s3_provider::remove_file_impl(const std::string &api_path) -> api_error {
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
curl::requests::http_delete del{}; curl::requests::http_delete del{};
@ -948,8 +948,8 @@ auto s3_provider::upload_file_impl(const std::string &api_path,
file_size = opt_size.value(); file_size = opt_size.value();
} }
const auto cfg = get_config().get_s3_config(); auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty(); auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
@ -959,7 +959,7 @@ auto s3_provider::upload_file_impl(const std::string &api_path,
} }
} }
const auto object_name = auto object_name =
utils::path::create_api_path(is_encrypted ? key : api_path); utils::path::create_api_path(is_encrypted ? key : api_path);
curl::requests::http_put_file put_file{}; curl::requests::http_put_file put_file{};