[unit test] Complete FUSE unit tests #22

This commit is contained in:
2025-09-27 08:15:12 -05:00
parent ae0ceb7040
commit cf68a7effe

View File

@@ -470,13 +470,9 @@ auto s3_provider::get_directory_items_impl(const std::string &api_path,
auto grab_more{true};
std::string token{};
std::unordered_set<std::string> seen_prefixes;
std::unordered_set<std::string> seen_keys;
auto api_path_prefix = utils::path::create_api_path(prefix);
while (grab_more) {
long response_code{};
std::string response_data{};
long response_code{};
if (not get_object_list(response_data, response_code, "/", prefix, token)) {
return api_error::comm_error;
}
@@ -508,56 +504,31 @@ auto s3_provider::get_directory_items_impl(const std::string &api_path,
.as_string();
}
for (const auto &node :
doc.select_nodes("/ListBucketResult/CommonPrefixes/Prefix")) {
std::string cur_prefix = node.node().text().as_string();
if (cur_prefix.empty()) {
continue;
}
if (not prefix.empty() && not cur_prefix.starts_with(prefix)) {
continue;
}
if (not seen_prefixes.insert(cur_prefix).second) {
continue;
}
auto child_object_name =
utils::path::create_api_path(utils::path::combine("/", {cur_prefix}));
auto res = add_directory_item(child_object_name, true, node.node());
auto node_list{
doc.select_nodes("/ListBucketResult/CommonPrefixes/Prefix"),
};
for (const auto &node : node_list) {
auto child_object_name{
utils::path::create_api_path(
utils::path::combine("/", {node.node().text().as_string()})),
};
auto res{add_directory_item(child_object_name, true, node.node())};
if (res != api_error::success) {
return res;
}
}
for (const auto &node : doc.select_nodes("/ListBucketResult/Contents")) {
std::string cur_key = node.node().child("Key").text().as_string();
if (cur_key.empty()) {
node_list = doc.select_nodes("/ListBucketResult/Contents");
for (const 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)) {
continue;
}
if (not prefix.empty() && // and
(cur_key == prefix || // or
not cur_key.starts_with(prefix) || // or
utils::path::create_api_path(cur_key) == api_path_prefix)) {
continue;
}
if (cur_key.back() == '/') {
continue;
}
if (seen_prefixes.contains(cur_key + "/")) {
continue;
}
if (not seen_keys.insert(cur_key).second) {
continue;
}
auto child_object_name = utils::path::create_api_path(cur_key);
auto res = add_directory_item(child_object_name, false, node.node());
auto res{add_directory_item(child_object_name, false, node.node())};
if (res != api_error::success) {
return res;
}