MCPcopy Create free account
hub / github.com/apache/arrow / DoDeleteDirContentsAsync

Method DoDeleteDirContentsAsync

cpp/src/arrow/filesystem/s3fs.cc:2852–2894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2850 }
2851
2852 Future<> DoDeleteDirContentsAsync(const std::string& bucket, const std::string& key) {
2853 return RunInScheduler(
2854 [bucket, key](util::AsyncTaskScheduler* scheduler, S3FileSystem::Impl* self) {
2855 scheduler->AddSimpleTask(
2856 [=] {
2857 FileSelector select;
2858 select.base_dir = bucket + kSep + key;
2859 select.recursive = true;
2860 select.allow_not_found = false;
2861
2862 FileInfoGenerator file_infos = self->GetFileInfoGenerator(select);
2863
2864 auto handle_file_infos = [=](const std::vector<FileInfo>& file_infos) {
2865 std::vector<std::string> file_paths;
2866 for (const auto& file_info : file_infos) {
2867 DCHECK_GT(file_info.path().size(), bucket.size());
2868 auto file_path = file_info.path().substr(bucket.size() + 1);
2869 if (file_info.IsDirectory()) {
2870 // The selector returns FileInfo objects for directories with a
2871 // a path that never ends in a trailing slash, but for AWS the file
2872 // needs to have a trailing slash to recognize it as directory
2873 // (https://github.com/apache/arrow/issues/38618)
2874 DCHECK_OK(internal::AssertNoTrailingSlash(file_path));
2875 file_path = file_path + kSep;
2876 }
2877 file_paths.push_back(std::move(file_path));
2878 }
2879 scheduler->AddSimpleTask(
2880 [=, file_paths = std::move(file_paths)] {
2881 return self->DeleteObjectsAsync(bucket, file_paths);
2882 },
2883 std::string_view("DeleteDirContentsDeleteTask"));
2884 return Status::OK();
2885 };
2886
2887 return VisitAsyncGenerator(
2888 AsyncGenerator<std::vector<FileInfo>>(std::move(file_infos)),
2889 std::move(handle_file_infos));
2890 },
2891 std::string_view("ListFilesForDelete"));
2892 return Status::OK();
2893 });
2894 }
2895
2896 Future<> DeleteDirContentsAsync(const std::string& bucket, const std::string& key) {
2897 auto self = shared_from_this();

Callers 1

Calls 10

GetFileInfoGeneratorMethod · 0.95
DeleteObjectsAsyncMethod · 0.95
AssertNoTrailingSlashFunction · 0.85
VisitAsyncGeneratorFunction · 0.85
substrMethod · 0.80
push_backMethod · 0.80
OKFunction · 0.50
sizeMethod · 0.45
pathMethod · 0.45
IsDirectoryMethod · 0.45

Tested by

no test coverage detected