| 2469 | } |
| 2470 | |
| 2471 | Result<bool> IsNonEmptyDirectory(const S3Path& path) { |
| 2472 | ARROW_ASSIGN_OR_RAISE(auto client_lock, holder_->Lock()); |
| 2473 | |
| 2474 | S3Model::ListObjectsV2Request req; |
| 2475 | req.SetBucket(ToAwsString(path.bucket)); |
| 2476 | req.SetPrefix(ToAwsString(path.key) + kSep); |
| 2477 | req.SetDelimiter(Aws::String() + kSep); |
| 2478 | req.SetMaxKeys(1); |
| 2479 | auto outcome = client_lock.Move()->ListObjectsV2(req); |
| 2480 | if (outcome.IsSuccess()) { |
| 2481 | const S3Model::ListObjectsV2Result& r = outcome.GetResult(); |
| 2482 | // In some cases, there may be 0 keys but some prefixes |
| 2483 | return r.GetKeyCount() > 0 || !r.GetCommonPrefixes().empty(); |
| 2484 | } |
| 2485 | if (IsNotFound(outcome.GetError())) { |
| 2486 | return false; |
| 2487 | } |
| 2488 | return ErrorToStatus( |
| 2489 | std::forward_as_tuple("When listing objects under key '", path.key, |
| 2490 | "' in bucket '", path.bucket, "': "), |
| 2491 | "ListObjectsV2", outcome.GetError()); |
| 2492 | } |
| 2493 | |
| 2494 | static FileInfo MakeDirectoryInfo(std::string dirname) { |
| 2495 | FileInfo dir; |
no test coverage detected