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

Method DeleteFile

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

Source from the content-addressed store, hash-verified

3369}
3370
3371Status S3FileSystem::DeleteFile(const std::string& s) {
3372 ARROW_ASSIGN_OR_RAISE(auto client_lock, impl_->holder_->Lock());
3373
3374 ARROW_ASSIGN_OR_RAISE(auto path, S3Path::FromString(s));
3375 RETURN_NOT_OK(ValidateFilePath(path));
3376
3377 // Check the object exists
3378 S3Model::HeadObjectRequest req;
3379 req.SetBucket(ToAwsString(path.bucket));
3380 req.SetKey(ToAwsString(path.key));
3381
3382 auto outcome = client_lock.Move()->HeadObject(req);
3383 if (!outcome.IsSuccess()) {
3384 if (IsNotFound(outcome.GetError())) {
3385 return PathNotFound(path);
3386 } else {
3387 return ErrorToStatus(
3388 std::forward_as_tuple("When getting information for key '", path.key,
3389 "' in bucket '", path.bucket, "': "),
3390 "HeadObject", outcome.GetError());
3391 }
3392 }
3393 // Object found, delete it
3394 RETURN_NOT_OK(impl_->DeleteObject(path.bucket, path.key));
3395 // Parent may be implicitly deleted if it became empty, recreate it
3396 return impl_->EnsureParentExists(path);
3397}
3398
3399Status S3FileSystem::Move(const std::string& src, const std::string& dest) {
3400 // 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