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

Method EnsureIsDirAsync

cpp/src/arrow/filesystem/s3fs.cc:2861–2888  ·  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

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