refactor
This commit is contained in:
parent
3814b9797d
commit
04f50f7453
@ -799,14 +799,17 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (is_encrypted) {
|
if (not is_encrypted) {
|
||||||
|
return read_bytes(size, offset, data);
|
||||||
|
}
|
||||||
|
|
||||||
std::string temp;
|
std::string temp;
|
||||||
auto res = get_item_meta(api_path, META_SIZE, temp);
|
auto res = get_item_meta(api_path, META_SIZE, temp);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
const auto total_size = utils::string::to_uint64(temp);
|
|
||||||
|
|
||||||
|
const 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>(
|
||||||
@ -820,9 +823,7 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
|
|||||||
total_size, data)
|
total_size, data)
|
||||||
? api_error::success
|
? api_error::success
|
||||||
: api_error::decryption_error;
|
: api_error::decryption_error;
|
||||||
}
|
|
||||||
|
|
||||||
return read_bytes(size, offset, data);
|
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
utils::error::raise_error(function_name, e, "exception occurred");
|
utils::error::raise_error(function_name, e, "exception occurred");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user