-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s3fs rmdir command returns error when given a valid s3 path #689
Comments
Can you share the exact code you executed? |
@martindurant apologies for the delay. Here is the code i used
Error: |
Same here. It returns the same error. |
The error occurs because rmdir invokes delete_bucket and passes the entire path as the name of the bucket. async def _rmdir(self, path):
try:
await self._call_s3("delete_bucket", Bucket=path)
... Based on the code, it appears that |
Yes, agree with everything here. Something like the following then? --- a/s3fs/core.py
+++ b/s3fs/core.py
@@ -899,6 +899,12 @@ class S3FileSystem(AsyncFileSystem):
makedirs = sync_wrapper(_makedirs)
async def _rmdir(self, path):
+ bucket, key = self.split_path(path)
+ if key:
+ if await self._exists(path):
+ # did you mean rm(path, recursive=True) ?
+ raise FileExistsError
+ raise FileNotFoundError
try:
await self._call_s3("delete_bucket", Bucket=path) i.e., in S3, a directory rather than a bucket can only exist if it contains something, so rmdir is always an exception. |
Issue:
I have s3 uri that points to empty folder, i have verified the uri is valid by checking the path with fs.isdir and fs.info and both return valid responses. However when i go and use the rmdir command i get the following error:
Invalid bucket name: Bucket name must match the regex "^[a-zA-Z0-9.-_]{1,255}$" or be an ARN matching the regex "^arn:(aws).:(s3|s3-object-lambda):[a-z-0-9]:[0-9]{12}:accesspoint[/:][a-zA-Z0-9-.]{1,63}$|^arn:(aws).*:s3-outposts:[a-z-0-9]+:[0-9]{12}:outpost[/:][a-zA-Z0-9-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9-]{1,63}$"
How is this function supposed to be used?
Version info:
Python 3.11.1
sf3s 2011.11.0
The text was updated successfully, but these errors were encountered: