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

Method DeleteFile

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

Source from the content-addressed store, hash-verified

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