This commit is contained in:
2024-08-23 21:38:47 -05:00
parent f7dbbb9707
commit 089be73a08

View File

@ -887,20 +887,18 @@ void s3_provider::stop() {
auto s3_provider::upload_file_impl(const std::string &api_path, auto s3_provider::upload_file_impl(const std::string &api_path,
const std::string &source_path, const std::string &source_path,
stop_type &stop_requested) -> api_error { stop_type &stop_requested) -> api_error {
std::uint64_t file_size{};
auto file = utils::file::file{source_path}; auto file = utils::file::file{source_path};
if (not file.exists()) { if (file.exists()) {
return api_error::comm_error; auto opt_size = file.size();
if (not opt_size.has_value()) {
return api_error::comm_error;
}
file_size = opt_size.value();
} }
auto opt_size = file.size(); auto cfg = get_config().get_s3_config();
if (not opt_size.has_value()) { auto is_encrypted = not cfg.encryption_token.empty();
return api_error::comm_error;
}
auto file_size{opt_size.value()};
const auto cfg = get_config().get_s3_config();
const auto is_encrypted = not cfg.encryption_token.empty();
std::string key; std::string key;
if (is_encrypted) { if (is_encrypted) {
@ -910,7 +908,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{};