refactor
This commit is contained in:
		| @@ -417,27 +417,29 @@ 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)) { | ||||
|       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 { | ||||
|       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) { | ||||
|                            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:: | ||||
|                            return is_encrypted | ||||
|                                       ? utils::encryption::encrypting_reader:: | ||||
|                                             calculate_decrypted_size(size) | ||||
|                                       : size; | ||||
|                          }); | ||||
|     } | ||||
|   } | ||||
|   } | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
| @@ -521,7 +523,10 @@ 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, "/")) { | ||||
|     if (utils::string::ends_with(api_path, "/")) { | ||||
|       continue; | ||||
|     } | ||||
|  | ||||
|     auto is_encrypted = | ||||
|         not get_config().get_s3_config().encryption_token.empty(); | ||||
|     if (is_encrypted) { | ||||
| @@ -537,11 +542,8 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const | ||||
|     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.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( | ||||
| @@ -555,7 +557,6 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const | ||||
|  | ||||
|     list.push_back(std::move(file)); | ||||
|   } | ||||
|   } | ||||
|  | ||||
|   return grab_more ? api_error::more_data : api_error::success; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user