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

Method DoDeleteDirContentsAsync

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

Source from the content-addressed store, hash-verified

2909 }
2910
2911 Future<> DoDeleteDirContentsAsync(const std::string& bucket, const std::string& key) {
2912 return RunInScheduler(
2913 [bucket, key](util::AsyncTaskScheduler* scheduler, S3FileSystem::Impl* self) {
2914 scheduler->AddSimpleTask(
2915 [=] {
2916 FileSelector select;
2917 select.base_dir = bucket + kSep + key;
2918 select.recursive = true;
2919 select.allow_not_found = false;
2920
2921 FileInfoGenerator file_infos = self->GetFileInfoGenerator(select);
2922
2923 auto handle_file_infos = [=](const std::vector<FileInfo>& file_infos) {
2924 std::vector<std::string> file_paths;
2925 for (const auto& file_info : file_infos) {
2926 DCHECK_GT(file_info.path().size(), bucket.size());
2927 auto file_path = file_info.path().substr(bucket.size() + 1);
2928 if (file_info.IsDirectory()) {
2929 // The selector returns FileInfo objects for directories with a
2930 // a path that never ends in a trailing slash, but for AWS the file
2931 // needs to have a trailing slash to recognize it as directory
2932 // (https://github.com/apache/arrow/issues/38618)
2933 DCHECK_OK(internal::AssertNoTrailingSlash(file_path));
2934 file_path = file_path + kSep;
2935 }
2936 file_paths.push_back(std::move(file_path));
2937 }
2938 scheduler->AddSimpleTask(
2939 [=, file_paths = std::move(file_paths)] {
2940 return self->DeleteObjectsAsync(bucket, file_paths);
2941 },
2942 std::string_view("DeleteDirContentsDeleteTask"));
2943 return Status::OK();
2944 };
2945
2946 return VisitAsyncGenerator(
2947 AsyncGenerator<std::vector<FileInfo>>(std::move(file_infos)),
2948 std::move(handle_file_infos));
2949 },
2950 std::string_view("ListFilesForDelete"));
2951 return Status::OK();
2952 });
2953 }
2954
2955 Future<> DeleteDirContentsAsync(const std::string& bucket, const std::string& key) {
2956 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