westonpace commented on code in PR #35440:
URL: https://github.com/apache/arrow/pull/35440#discussion_r1267379629


##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -2312,35 +2287,137 @@ class S3FileSystem::Impl : public 
std::enable_shared_from_this<S3FileSystem::Imp
       futures.push_back(std::move(fut));
     }
 
-    return AllComplete(futures);
+    return AllFinished(futures);
   }
 
   Status DeleteObjects(const std::string& bucket, const 
std::vector<std::string>& keys) {
     return DeleteObjectsAsync(bucket, keys).status();
   }
 
+  Future<> EnsureNotFileAsync(const std::string& bucket, const std::string& 
key) {
+    if (key.empty()) {
+      // There is no way for a bucket to be a file
+      return Future<>::MakeFinished();
+    }
+    auto self = shared_from_this();
+    return DeferNotOk(SubmitIO(io_context_, [self, bucket, key]() mutable -> 
Status {
+      S3Model::HeadObjectRequest req;
+      req.SetBucket(ToAwsString(bucket));
+      req.SetKey(ToAwsString(key));
+
+      ARROW_ASSIGN_OR_RAISE(auto client_lock, self->holder_->Lock());
+      auto outcome = client_lock.Move()->HeadObject(req);
+      if (outcome.IsSuccess()) {
+        const auto& result = outcome.GetResult();
+        if (result.GetContentLength() > 0 || key[key.size() - 1] != '/') {
+          return Status::IOError("Cannot delete directory contents at ", 
bucket, kSep,
+                                 key, " because it is a file");
+        }

Review Comment:
   I changed the method to `EnsureIsDirAsync` and changed it so that it returns 
`Result<bool>` and moved the error message into `DeleteDirContentsAsync`.



-- 
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]

Reply via email to