| 589 | } |
| 590 | |
| 591 | std::vector<URI> ArrayDirectory::ls(const URI& uri) const { |
| 592 | auto dir_entries = resources_.get().vfs().ls_with_sizes(uri); |
| 593 | auto& dirs = dir_names(); |
| 594 | std::vector<URI> uris; |
| 595 | uris.reserve(dir_entries.size()); |
| 596 | |
| 597 | for (auto entry : dir_entries) { |
| 598 | auto entry_uri = URI(entry.path().native()); |
| 599 | |
| 600 | // Always list directories |
| 601 | if (entry.is_directory()) { |
| 602 | uris.emplace_back(entry_uri); |
| 603 | continue; |
| 604 | } |
| 605 | |
| 606 | // Filter out empty files of the same name as the directory |
| 607 | if (entry_uri.remove_trailing_slash() == uri.remove_trailing_slash() && |
| 608 | entry.file_size() == 0) { |
| 609 | continue; |
| 610 | } |
| 611 | |
| 612 | // List non-known (user-added) directory names and non-empty files |
| 613 | auto iter = dirs.find(entry_uri.last_path_part()); |
| 614 | if (iter == dirs.end() || entry.file_size() > 0) { |
| 615 | uris.emplace_back(entry_uri); |
| 616 | } else { |
| 617 | // Handle MinIO-based s3 implementation limitation. If an object exists |
| 618 | // with the same name as a directory, the objects under the directory are |
| 619 | // masked and cannot be listed. See |
| 620 | // https://github.com/minio/minio/issues/7335 |
| 621 | throw ArrayDirectoryException( |
| 622 | "Cannot list given uri; File '" + entry_uri.to_string() + |
| 623 | "' may be masking a non-empty directory by the same name. Removing " |
| 624 | "that file might fix this."); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | return uris; |
| 629 | } |
| 630 | |
| 631 | std::vector<URI> ArrayDirectory::list_root_dir_uris() { |
| 632 | // List the array directory URIs |
nothing calls this directly
no test coverage detected