thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.34k stars 827 forks source link

Expected behaviour deleting a directory that does not exist? #1099

Closed judgej closed 4 years ago

judgej commented 4 years ago

Question

I cannot find this in the docs, nor find this question raised anywhere else yet. I'm putting together some live tests for a driver, and it is throwing up questions like this.

A request to delete a directory - deleteDir() - that does not exist - what should the driver do? There is no API method to check if a directory exists, and there is no defined behavior when using has() when pointing at a file.

The deleteDir() method defines a boolean return, but does not state what that return value means. Should it return false if the directory does not exist? Then true if if did exist and was deleted? What about if it did exist but could not be deleted? Or surely if the directory does not exist in the first place, then asking for it to be deleted is just confirming that the state is what has been requested, so should return true? Then when should false ever be used? This method also does not define any exceptions that is expected to be thrown.

My current assumption is:

But that's just my assumption. Frameworks such as Laravel may have made different assumptions (and this, I believe, is where I am actually running into problems in a project).

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.