| 3369 | } |
| 3370 | |
| 3371 | Status 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 | |
| 3399 | Status S3FileSystem::Move(const std::string& src, const std::string& dest) { |
| 3400 | // XXX We don't implement moving directories as it would be too expensive: |