pitrou commented on code in PR #12848:
URL: https://github.com/apache/arrow/pull/12848#discussion_r853221035
##########
cpp/src/arrow/filesystem/gcsfs.cc:
##########
@@ -477,10 +478,22 @@ class GcsFileSystem::Impl {
std::vector<Future<>> submitted;
// This iterates over all the objects, and schedules parallel deletes.
auto prefix = p.object.empty() ? gcs::Prefix() : gcs::Prefix(canonical);
+ bool at_least_one_obj = false;
for (const auto& o : client_.ListObjects(p.bucket, prefix)) {
+ at_least_one_obj = true;
submitted.push_back(DeferNotOk(io_context.executor()->Submit(async_delete, o)));
}
+ if (!missing_dir_ok && !at_least_one_obj) {
+ // If any files were found the directory implicitly exists. If none were
+ // found then we still have to consider a marker-only directory so we
test
+ // for that.
+ ARROW_ASSIGN_OR_RAISE(auto file_info, GetFileInfo(p));
+ if (file_info.type() == FileType::NotFound) {
+ return Status::IOError("No directory or any files matching path: ",
p.full_path);
+ }
+ }
Review Comment:
Hmm, I think you can reuse the `dir` variable introduced above?
```suggestion
if (!missing_dir_ok && !at_least_one_obj && !dir) {
// No files were found and no directory marker exists
return Status::IOError("No such directory: ", p.full_path);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]