This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user