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

Method DeleteFile

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

Source from the content-addressed store, hash-verified

3302}
3303
3304Status S3FileSystem::DeleteFile(const std::string& s) {
3305 ARROW_ASSIGN_OR_RAISE(auto client_lock, impl_->holder_->Lock());
3306
3307 ARROW_ASSIGN_OR_RAISE(auto path, S3Path::FromString(s));
3308 RETURN_NOT_OK(ValidateFilePath(path));
3309
3310 // Check the object exists
3311 S3Model::HeadObjectRequest req;
3312 req.SetBucket(ToAwsString(path.bucket));
3313 req.SetKey(ToAwsString(path.key));
3314
3315 auto outcome = client_lock.Move()->HeadObject(req);
3316 if (!outcome.IsSuccess()) {
3317 if (IsNotFound(outcome.GetError())) {
3318 return PathNotFound(path);
3319 } else {
3320 return ErrorToStatus(
3321 std::forward_as_tuple("When getting information for key '", path.key,
3322 "' in bucket '", path.bucket, "': "),
3323 "HeadObject", outcome.GetError());
3324 }
3325 }
3326 // Object found, delete it
3327 RETURN_NOT_OK(impl_->DeleteObject(path.bucket, path.key));
3328 // Parent may be implicitly deleted if it became empty, recreate it
3329 return impl_->EnsureParentExists(path);
3330}
3331
3332Status S3FileSystem::Move(const std::string& src, const std::string& dest) {
3333 // XXX We don't implement moving directories as it would be too expensive:

Callers 8

TEST_FFunction · 0.45
TEST_FFunction · 0.45
TestDeleteFileMethod · 0.45
TestSpecialCharsMethod · 0.45
TEST_FFunction · 0.45
RemoveMaterialMethod · 0.45

Calls 8

ValidateFilePathFunction · 0.85
ToAwsStringFunction · 0.85
IsNotFoundFunction · 0.85
ErrorToStatusFunction · 0.85
DeleteObjectMethod · 0.80
EnsureParentExistsMethod · 0.80
PathNotFoundFunction · 0.70
MoveMethod · 0.45

Tested by 5

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TestDeleteFileMethod · 0.36
TestSpecialCharsMethod · 0.36
TEST_FFunction · 0.36