| 2410 | } |
| 2411 | |
| 2412 | Result<bool> IsNonEmptyDirectory(const S3Path& path) { |
| 2413 | ARROW_ASSIGN_OR_RAISE(auto client_lock, holder_->Lock()); |
| 2414 | |
| 2415 | S3Model::ListObjectsV2Request req; |
| 2416 | req.SetBucket(ToAwsString(path.bucket)); |
| 2417 | req.SetPrefix(ToAwsString(path.key) + kSep); |
| 2418 | req.SetDelimiter(Aws::String() + kSep); |
| 2419 | req.SetMaxKeys(1); |
| 2420 | auto outcome = client_lock.Move()->ListObjectsV2(req); |
| 2421 | if (outcome.IsSuccess()) { |
| 2422 | const S3Model::ListObjectsV2Result& r = outcome.GetResult(); |
| 2423 | // In some cases, there may be 0 keys but some prefixes |
| 2424 | return r.GetKeyCount() > 0 || !r.GetCommonPrefixes().empty(); |
| 2425 | } |
| 2426 | if (IsNotFound(outcome.GetError())) { |
| 2427 | return false; |
| 2428 | } |
| 2429 | return ErrorToStatus( |
| 2430 | std::forward_as_tuple("When listing objects under key '", path.key, |
| 2431 | "' in bucket '", path.bucket, "': "), |
| 2432 | "ListObjectsV2", outcome.GetError()); |
| 2433 | } |
| 2434 | |
| 2435 | static FileInfo MakeDirectoryInfo(std::string dirname) { |
| 2436 | FileInfo dir; |
no test coverage detected