refactor
This commit is contained in:
parent
44d810c398
commit
3814b9797d
@ -417,25 +417,27 @@ auto s3_provider::get_directory_items_impl(const std::string &api_path,
|
||||
for (auto &&node : node_list) {
|
||||
auto child_object_name = utils::path::create_api_path(
|
||||
node.node().select_node("Key").node().text().as_string());
|
||||
if (child_object_name != utils::path::create_api_path(prefix)) {
|
||||
auto size = node.node().select_node("Size").node().text().as_ullong();
|
||||
auto last_modified = convert_api_date(
|
||||
node.node().select_node("LastModified").node().text().as_string());
|
||||
add_directory_item(
|
||||
false, child_object_name, last_modified,
|
||||
[this, &is_encrypted,
|
||||
&size](const directory_item &dir_item) -> std::uint64_t {
|
||||
std::string size_str;
|
||||
if (get_item_meta(dir_item.api_path, META_SIZE, size_str) ==
|
||||
api_error::success) {
|
||||
return utils::string::to_uint64(size_str);
|
||||
}
|
||||
|
||||
return is_encrypted ? utils::encryption::encrypting_reader::
|
||||
calculate_decrypted_size(size)
|
||||
: size;
|
||||
});
|
||||
if (child_object_name == utils::path::create_api_path(prefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto size = node.node().select_node("Size").node().text().as_ullong();
|
||||
auto last_modified = convert_api_date(
|
||||
node.node().select_node("LastModified").node().text().as_string());
|
||||
add_directory_item(false, child_object_name, last_modified,
|
||||
[this, &is_encrypted, &size](
|
||||
const directory_item &dir_item) -> std::uint64_t {
|
||||
std::string size_str;
|
||||
if (get_item_meta(dir_item.api_path, META_SIZE,
|
||||
size_str) == api_error::success) {
|
||||
return utils::string::to_uint64(size_str);
|
||||
}
|
||||
|
||||
return is_encrypted
|
||||
? utils::encryption::encrypting_reader::
|
||||
calculate_decrypted_size(size)
|
||||
: size;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,40 +523,39 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
|
||||
for (auto &&node : node_list) {
|
||||
auto api_path =
|
||||
std::string{node.node().select_node("Key").node().text().as_string()};
|
||||
if (not utils::string::ends_with(api_path, "/")) {
|
||||
auto is_encrypted =
|
||||
not get_config().get_s3_config().encryption_token.empty();
|
||||
if (is_encrypted) {
|
||||
auto err = decrypt_object_name(api_path);
|
||||
if (err != api_error::success) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
if (utils::string::ends_with(api_path, "/")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto size = node.node().select_node("Size").node().text().as_ullong();
|
||||
|
||||
api_file file{};
|
||||
file.api_path = utils::path::create_api_path(api_path);
|
||||
file.api_parent = utils::path::get_parent_api_path(file.api_path);
|
||||
file.accessed_date = file.changed_date = file.creation_date =
|
||||
file.modified_date = convert_api_date(node.node()
|
||||
.select_node("LastModified")
|
||||
.node()
|
||||
.text()
|
||||
.as_string());
|
||||
file.file_size =
|
||||
is_encrypted
|
||||
? utils::encryption::encrypting_reader::calculate_decrypted_size(
|
||||
size)
|
||||
: size;
|
||||
file.key = is_encrypted ? utils::path::create_api_path(api_path) : "";
|
||||
auto err = add_if_not_found(file, api_path);
|
||||
auto is_encrypted =
|
||||
not get_config().get_s3_config().encryption_token.empty();
|
||||
if (is_encrypted) {
|
||||
auto err = decrypt_object_name(api_path);
|
||||
if (err != api_error::success) {
|
||||
return err;
|
||||
}
|
||||
|
||||
list.push_back(std::move(file));
|
||||
}
|
||||
|
||||
auto size = node.node().select_node("Size").node().text().as_ullong();
|
||||
|
||||
api_file file{};
|
||||
file.api_path = utils::path::create_api_path(api_path);
|
||||
file.api_parent = utils::path::get_parent_api_path(file.api_path);
|
||||
file.accessed_date = file.changed_date = file.creation_date =
|
||||
file.modified_date = convert_api_date(
|
||||
node.node().select_node("LastModified").node().text().as_string());
|
||||
file.file_size =
|
||||
is_encrypted
|
||||
? utils::encryption::encrypting_reader::calculate_decrypted_size(
|
||||
size)
|
||||
: size;
|
||||
file.key = is_encrypted ? utils::path::create_api_path(api_path) : "";
|
||||
auto err = add_if_not_found(file, api_path);
|
||||
if (err != api_error::success) {
|
||||
return err;
|
||||
}
|
||||
|
||||
list.push_back(std::move(file));
|
||||
}
|
||||
|
||||
return grab_more ? api_error::more_data : api_error::success;
|
||||
|
Loading…
x
Reference in New Issue
Block a user