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

Method DoDeleteDirContentsAsync

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

Source from the content-addressed store, hash-verified

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