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

Method DeleteDir

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

Source from the content-addressed store, hash-verified

3315}
3316
3317Status S3FileSystem::DeleteDir(const std::string& s) {
3318 ARROW_ASSIGN_OR_RAISE(auto path, S3Path::FromString(s));
3319 if (path.empty()) {
3320 return Status::NotImplemented("Cannot delete all S3 buckets");
3321 }
3322 RETURN_NOT_OK(impl_->DeleteDirContentsAsync(path.bucket, path.key).status());
3323 if (path.key.empty() && options().allow_bucket_deletion) {
3324 // Delete bucket
3325 ARROW_ASSIGN_OR_RAISE(auto client_lock, impl_->holder_->Lock());
3326 S3Model::DeleteBucketRequest req;
3327 req.SetBucket(ToAwsString(path.bucket));
3328 return OutcomeToStatus(
3329 std::forward_as_tuple("When deleting bucket '", path.bucket, "': "),
3330 "DeleteBucket", client_lock.Move()->DeleteBucket(req));
3331 } else if (path.key.empty()) {
3332 return Status::IOError("Would delete bucket '", path.bucket, "'. ",
3333 "To delete buckets, enable the allow_bucket_deletion option.");
3334 } else {
3335 // Delete "directory"
3336 RETURN_NOT_OK(impl_->DeleteObject(path.bucket, path.key + kSep));
3337 // Parent may be implicitly deleted if it became empty, recreate it
3338 return impl_->EnsureParentExists(path);
3339 }
3340}
3341
3342Status S3FileSystem::DeleteDirContents(const std::string& s, bool missing_dir_ok) {
3343 return DeleteDirContentsAsync(s, missing_dir_ok).status();

Callers 12

TEST_FFunction · 0.45
TestFileSystemFromUriMethod · 0.45
TestGetFileInfoMethod · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TestDeleteDirMethod · 0.45
TestSpecialCharsMethod · 0.45
TEST_FFunction · 0.45
TearDownMethod · 0.45
TEST_FFunction · 0.45

Calls 11

optionsFunction · 0.85
ToAwsStringFunction · 0.85
OutcomeToStatusFunction · 0.85
IOErrorFunction · 0.85
DeleteObjectMethod · 0.80
EnsureParentExistsMethod · 0.80
NotImplementedFunction · 0.50
emptyMethod · 0.45
statusMethod · 0.45
MoveMethod · 0.45

Tested by 10

TEST_FFunction · 0.36
TestFileSystemFromUriMethod · 0.36
TestGetFileInfoMethod · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
TestDeleteDirMethod · 0.36
TestSpecialCharsMethod · 0.36
TEST_FFunction · 0.36
TearDownMethod · 0.36
TEST_FFunction · 0.36