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
S3 Adapter can't delete "folders" #182
Comments
+1 |
1 similar comment
+1 |
Isn't that a really, really dangerous change to make? A simple typo could delete the entire contents of a bucket. However, I think that Gaufrette should allow you to delete single objects or delete an empty bucket. |
@mtdowling I don't see how it is more dangerous than a typo in a usual file system path. |
I don't know if this is fixed but I vote for it. 👍 |
+1 |
2 similar comments
+1 |
+1 |
Oh noes, putting responsibility on the developer! 😨 How do you ever delete a local folder then without getting a heart attack? 😄 |
I think @mtdowling is right: adding a method to delete every objects in a bucket is pretty dangerous. In the other hand I think Filesystem abstraction and underlying adapters are lacking such a feature (deleting multiple objects based on a pattern). So I would a consider a new method in Filesystem based on a new interface and an opt-in option |
@NiR- Again, how is it different from deleting a local directory? If we follow that argument i vote for removing the |
@NiR- the behaviour across adaptors should be consistent. I think the better way is that any storage system allows deleting of folders / buckets / whatever. If some people are scared simply add a new option that disables deleting of non-empty "folders". This should solve the problem and give people the option instead of forcing a direction. |
S3 does not know folders but you can use keys that mimic folders like /some/folders/myfile.txt.
By looking at the delete method of the S3 adapter you can see it is only deleting a single object. https://github.com/KnpLabs/Gaufrette/blob/master/src/Gaufrette/Adapter/AmazonS3.php#L195
The old version of the AWS SDK Gaufrette is using offers a method delete_all_objects() https://github.com/amazonwebservices/aws-sdk-for-php/blob/master/services/s3.class.php#L2603 which takes wildcards and by this allows you to delete all objects within a given namespace like /some/* would delete /some/folders/myfile.txt.
I propose to change the adapter to check if the given object "isDirectory()" and and if yes call delete_all_objects().
Let me know if you agree and I might create a PR for that.
The text was updated successfully, but these errors were encountered: