]> source.dussan.org Git - nextcloud-server.git/commitdiff
make rmdir recursive for mappellocal storage backend
authorRobin Appelman <icewind@owncloud.com>
Sun, 30 Jun 2013 15:44:49 +0000 (17:44 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 3 Dec 2013 10:45:08 +0000 (11:45 +0100)
Backported from d051d6f9252de915a13e1b053c54f69bcd83f5ee

lib/files/storage/mappedlocal.php

index 0cdba326642da3daec05b8166fd56f2dbbf07b95..ba5ac4191c5b9b1fc595fb472c2c17125bd0a2d4 100644 (file)
@@ -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('.', '..');