| 340 | const GcsOptions& options() const { return options_; } |
| 341 | |
| 342 | Result<FileInfo> GetFileInfo(const GcsPath& path) { |
| 343 | if (path.object.empty()) { |
| 344 | auto meta = client_.GetBucketMetadata(path.bucket); |
| 345 | return GetFileInfoBucket(path, std::move(meta).status()); |
| 346 | } |
| 347 | auto meta = client_.GetObjectMetadata(path.bucket, path.object); |
| 348 | Result<FileInfo> info = GetFileInfoObject(path, meta); |
| 349 | if (!info.ok() || info->type() != FileType::NotFound) { |
| 350 | return info; |
| 351 | } |
| 352 | // Not found case. It could be this was written to GCS with a different |
| 353 | // "Directory" convention, so if there is at least one object that |
| 354 | // matches the prefix we assume it is a directory. |
| 355 | std::string canonical = internal::EnsureTrailingSlash(path.object); |
| 356 | auto list_result = client_.ListObjects(path.bucket, gcs::Prefix(canonical)); |
| 357 | |
| 358 | for (auto&& object_metadata : list_result) { |
| 359 | if (!object_metadata) { |
| 360 | continue; |
| 361 | } |
| 362 | // If there is at least one valid result, it indicates this is a |
| 363 | // directory (at least one object exists that starts with "path/") |
| 364 | return FileInfo(path.full_path, FileType::Directory); |
| 365 | } |
| 366 | // Return the original not-found info if there was no valid result. |
| 367 | return info; |
| 368 | } |
| 369 | |
| 370 | Result<FileInfoVector> GetFileInfo(const FileSelector& select) { |
| 371 | ARROW_ASSIGN_OR_RAISE(auto p, GcsPath::FromString(select.base_dir)); |
nothing calls this directly
no test coverage detected