| 3302 | } |
| 3303 | |
| 3304 | Status 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 | |
| 3332 | Status S3FileSystem::Move(const std::string& src, const std::string& dest) { |
| 3333 | // XXX We don't implement moving directories as it would be too expensive: |