refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-01-01 01:19:59 -06:00
parent ecb9783f4e
commit 4fef036f10
2 changed files with 10 additions and 14 deletions

View File

@ -600,11 +600,11 @@ auto s3_provider::get_file_list(api_file_list &list,
for (const auto &node : node_list) {
auto object_name =
std::string{node.node().select_node("Key").node().text().as_string()};
auto api_path{object_name};
if (utils::string::ends_with(api_path, "/")) {
if (utils::string::ends_with(object_name, "/")) {
continue;
}
auto api_path{object_name};
auto is_encrypted = not get_s3_config().encryption_token.empty();
if (is_encrypted) {
auto res = decrypt_object_name(api_path);

View File

@ -25,26 +25,27 @@
#include "utils/collection.hpp"
#include "utils/encrypting_reader.hpp"
#include "utils/path.hpp"
namespace repertory::utils::encryption {
auto decrypt_file_path(std::string_view encryption_token,
std::string &file_path) -> bool {
std::string decrypted_file_path{};
std::vector<std::string> decrypted_parts;
for (const auto &part : std::filesystem::path(file_path)) {
auto file_name = part.string();
if (file_name == "/") {
continue;
}
auto res = decrypt_file_name(encryption_token, file_name);
if (not res) {
return res;
if (not decrypt_file_name(encryption_token, file_name)) {
return false;
}
decrypted_file_path += '/' + file_name;
decrypted_parts.push_back(file_name);
}
file_path = decrypted_file_path;
file_path =
utils::path::create_api_path(utils::string::join(decrypted_parts, '/'));
return true;
}
@ -56,12 +57,7 @@ auto decrypt_file_name(std::string_view encryption_token,
}
file_name.clear();
if (not utils::encryption::decrypt_data(encryption_token, buffer,
file_name)) {
return false;
}
return true;
return utils::encryption::decrypt_data(encryption_token, buffer, file_name);
}
#if defined(PROJECT_ENABLE_CURL)