{"action":"created","issue":{"url":"https://api.github.com/repos/enl/flysystem-cloudinary/issues/3","labels_url":"https://api.github.com/repos/enl/flysystem-cloudinary/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/enl/flysystem-cloudinary/issues/3/comments","events_url":"https://api.github.com/repos/enl/flysystem-cloudinary/issues/3/events","html_url":"https://github.com/enl/flysystem-cloudinary/issues/3","id":98936234,"number":3,"title":"Delete directory should remove all files within this directory","user":{"login":"tdutrion","id":1712222,"avatar_url":"https://avatars.githubusercontent.com/u/1712222?v=3","gravatar_id":"","url":"https://api.github.com/users/tdutrion","html_url":"https://github.com/tdutrion","followers_url":"https://api.github.com/users/tdutrion/followers","following_url":"https://api.github.com/users/tdutrion/following{/other_user}","gists_url":"https://api.github.com/users/tdutrion/gists{/gist_id}","starred_url":"https://api.github.com/users/tdutrion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdutrion/subscriptions","organizations_url":"https://api.github.com/users/tdutrion/orgs","repos_url":"https://api.github.com/users/tdutrion/repos","events_url":"https://api.github.com/users/tdutrion/events{/privacy}","received_events_url":"https://api.github.com/users/tdutrion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-04T10:14:40Z","updated_at":"2015-08-05T10:21:57Z","closed_at":null,"body":"According to the interface, we can not define the expected behaviour of the `deleteDir` method, but by looking at the [FTP adapter](https://github.com/thephpleague/flysystem/blob/master/src/Adapter/Ftp.php#L232) for instance, it seems like every files under the specified directory should be removed as well as the directory.\r\n\r\n```php\r\npublic function deleteDir($dirname)\r\n{\r\n    $connection = $this->getConnection();\r\n    $contents = array_reverse($this->listDirectoryContents($dirname));\r\n    foreach ($contents as $object) {\r\n        if ($object['type'] === 'file') {\r\n            if (! ftp_delete($connection, $object['path'])) {\r\n                return false;\r\n            }\r\n        } elseif (! ftp_rmdir($connection, $object['path'])) {\r\n            return false;\r\n        }\r\n    }\r\n    return ftp_rmdir($connection, $dirname);\r\n}\r\n```\r\n\r\nFor Cloudinary, directories are not supported, so the current implementation is raising an Exception (which by the way is not declared in the interface docblock).\r\n\r\n```php\r\n/**\r\n * Delete a directory.\r\n *\r\n * @param string $dirname\r\n * @return bool\r\n * @throws NotSupportedException\r\n */\r\npublic function deleteDir($dirname)\r\n{\r\n    throw new NotSupportedException('Cloudinary API does not support folders management.');\r\n}\r\n```\r\nvs\r\n```php\r\n/**\r\n * Delete a directory.\r\n *\r\n * @param string $dirname\r\n *\r\n * @return bool\r\n */\r\npublic function deleteDir($dirname);\r\n```\r\n\r\nThe problem is when someone tries to use the adapter to replace another one, the exception will be thrown where one expects to have a `return false;` or see all the files under the directory be deleted.\r\n\r\nI can make a PR but I first need to know what direction we should consider: either return false or delete all files from the path and return true. In the latter case, should we include an optional PSR-3 [LoggerInterface](https://github.com/php-fig/log/blob/master/Psr/Log/LoggerInterface.php) using the [LoggerAwareInterface](https://github.com/php-fig/log/blob/master/Psr/Log/LoggerAwareInterface.php) and the [LoggerAwareTrait](https://github.com/php-fig/log/blob/master/Psr/Log/LoggerAwareTrait.php)? Optionally we could initialise the logger to [NullLogger](https://github.com/php-fig/log/blob/master/Psr/Log/NullLogger.php) to avoid having to test whether a logger has been set."},"comment":{"url":"https://api.github.com/repos/enl/flysystem-cloudinary/issues/comments/127949407","html_url":"https://github.com/enl/flysystem-cloudinary/issues/3#issuecomment-127949407","issue_url":"https://api.github.com/repos/enl/flysystem-cloudinary/issues/3","id":127949407,"user":{"login":"frankdejonge","id":534693,"avatar_url":"https://avatars.githubusercontent.com/u/534693?v=3","gravatar_id":"","url":"https://api.github.com/users/frankdejonge","html_url":"https://github.com/frankdejonge","followers_url":"https://api.github.com/users/frankdejonge/followers","following_url":"https://api.github.com/users/frankdejonge/following{/other_user}","gists_url":"https://api.github.com/users/frankdejonge/gists{/gist_id}","starred_url":"https://api.github.com/users/frankdejonge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankdejonge/subscriptions","organizations_url":"https://api.github.com/users/frankdejonge/orgs","repos_url":"https://api.github.com/users/frankdejonge/repos","events_url":"https://api.github.com/users/frankdejonge/events{/privacy}","received_events_url":"https://api.github.com/users/frankdejonge/received_events","type":"User","site_admin":false},"created_at":"2015-08-05T10:21:57Z","updated_at":"2015-08-05T10:21:57Z","body":"@tdutrion the suggestion by @enl is correct. This is also how it's handled in other flat filesystems (like s3), directories are second grade citizens in Flysystem and are only used as a point of reference, like the \"prefix\" in cloudinary. In addition, methods like createDir can just return `true` since directories are an implicit concept in the underlying architecture."}}