MCPcopy Create free account
hub / github.com/apache/arrow / EnsureIsDirAsync

Method EnsureIsDirAsync

cpp/src/arrow/filesystem/s3fs.cc:2859–2886  ·  view source on GitHub ↗

Check to make sure the given path is not a file Returns true if the path seems to be a directory, false if it is a file

Source from the content-addressed store, hash-verified

2857 //
2858 // Returns true if the path seems to be a directory, false if it is a file
2859 Future<bool> EnsureIsDirAsync(const std::string& bucket, const std::string& key) {
2860 if (key.empty()) {
2861 // There is no way for a bucket to be a file
2862 return Future<bool>::MakeFinished(true);
2863 }
2864 auto self = shared_from_this();
2865 return DeferNotOk(
2866 SubmitIO(io_context_, [self, bucket, key]() mutable -> Result<bool> {
2867 S3Model::HeadObjectRequest req;
2868 req.SetBucket(ToAwsString(bucket));
2869 req.SetKey(ToAwsString(key));
2870
2871 ARROW_ASSIGN_OR_RAISE(auto client_lock, self->holder_->Lock());
2872 auto outcome = client_lock.Move()->HeadObject(req);
2873 if (outcome.IsSuccess()) {
2874 return IsDirectory(key, outcome.GetResult());
2875 }
2876 if (IsNotFound(outcome.GetError())) {
2877 // If we can't find it then it isn't a file.
2878 return true;
2879 } else {
2880 return ErrorToStatus(
2881 std::forward_as_tuple("When getting information for key '", key,
2882 "' in bucket '", bucket, "': "),
2883 "HeadObject", outcome.GetError());
2884 }
2885 }));
2886 }
2887
2888 // Some operations require running multiple S3 calls, either in parallel or serially. We
2889 // need to ensure that the S3 filesystem instance stays valid and that S3 isn't

Callers

nothing calls this directly

Calls 9

DeferNotOkFunction · 0.85
SubmitIOFunction · 0.85
ToAwsStringFunction · 0.85
IsNotFoundFunction · 0.85
ErrorToStatusFunction · 0.85
IsDirectoryFunction · 0.70
emptyMethod · 0.45
MoveMethod · 0.45
GetResultMethod · 0.45

Tested by

no test coverage detected