diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-06-06 22:47:20 +0400 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-12-03 13:47:26 +0400 |
commit | 6eef3c9c4c95a97d7446dfc8dda81114e612abf7 (patch) | |
tree | 51f9ef22633894109139efca96421f9f130de0f8 /lib | |
parent | a385e86e5822a3147c4dbf6fb30432ab91004b9f (diff) |
Make rmdir recursive for local storage
Backport of 63c898c0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/files/storage/local.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index f4d7626219b..a6fe01c63d6 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -34,7 +34,27 @@ class Local extends \OC\Files\Storage\Common{ return @mkdir($this->datadir.$path); } public function rmdir($path) { - return @rmdir($this->datadir.$path); + try { + $it = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($this->datadir . $path), + \RecursiveIteratorIterator::CHILD_FIRST + ); + foreach ($it as $file) { + /** + * @var \SplFileInfo $file + */ + if (in_array($file->getBasename(), array('.', '..'))) { + continue; + } elseif ($file->isDir()) { + rmdir($file->getPathname()); + } elseif ($file->isFile() || $file->isLink()) { + unlink($file->getPathname()); + } + } + return rmdir($this->datadir . $path); + } catch (\UnexpectedValueException $e) { + return false; + } } public function opendir($path) { return opendir($this->datadir.$path); |