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
| 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 |
nothing calls this directly
no test coverage detected