-
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 rm with recursive set as true doesn't work as one would expected #688
Comments
S3 does not have folders. You probably have a file with the same name as the original "folder", which it is reasonable not t have deleted. |
@martindurant here is a similar example for rm code.
The command executes, but when i check the s3 the file still exists |
@ianthomas23 , this could be seen as a follow-up to your work. The likely issue is the directory as a prefix versus a zero-length key.
So probably we should always attempt to delete directories as if they were keys, but allow it to fail silently. The exact same situation exists in gcsfs. |
@martindurant Yes, there are a few issues that are in the same areas of recursive actions with and without directories and files existing that I will work through. |
I think this is working as expected. If I add the following test def test_issue_688(s3):
dir = test_bucket_name + "/dir"
file = dir + "/file"
s3.touch(file)
assert s3.exists(dir)
assert s3.exists(file)
s3.rm(dir, recursive=True)
assert not s3.exists(dir)
assert not s3.exists(file) then it passes. Without the Unless I have misunderstood something here. |
I am going to close this as I don't think any action is required. Feel free to reopen if there is still an issue. |
I'm poking about here investigating silent errors and this statement rings huge warning bells! 🚨 If you call From the Zen of Python:
When I call |
xref: #838 |
Agreed, rm on an existing (non-empty) directory should raise IsADirectoryError. |
Using the s3fs rm with recursive set as true doesn't work as one would expected
When trying to delete any "directory" on s3 using the rm command the files instead the folder will be deleted, but the s3 directory will not be deleted.
Example:
using fs.rm(uri, recursive = True)
If I provide the s3 uri path root/dir_1/dir_2 --> only deletes the file and not the folders.
root/dir_1/dir_2/file_1 ---> only file_1 is deleted
Version Info:
Python: 3.11.1
s3fs = 2011.11.0
The text was updated successfully, but these errors were encountered: