diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-06-30 19:44:49 +0400 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-12-03 14:45:08 +0400 |
commit | 14be3b3dbb37d6bbd95c6086af79c7c65a8d39dd (patch) | |
tree | 0761038f6193c24227b67b9856ccb82ecb170d08 /lib | |
parent | 6eef3c9c4c95a97d7446dfc8dda81114e612abf7 (diff) |
make rmdir recursive for mappellocal storage backend
Backported from d051d6f9252de915a13e1b053c54f69bcd83f5ee
Diffstat (limited to 'lib')
-rw-r--r-- | lib/files/storage/mappedlocal.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index 0cdba326642..ba5ac4191c5 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -34,10 +34,30 @@ class MappedLocal extends \OC\Files\Storage\Common{ return @mkdir($this->buildPath($path)); } public function rmdir($path) { - if ($result = @rmdir($this->buildPath($path))) { - $this->cleanMapper($path); + try { + $it = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($this->buildPath($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()); + } + } + if ($result = @rmdir($this->buildPath($path))) { + $this->cleanMapper($path); + } + return $result; + } catch (\UnexpectedValueException $e) { + return false; } - return $result; } public function opendir($path) { $files = array('.', '..'); |