]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add support for copying/moving folders between storages, move isIgnoredDir() to Files...
authorMichael Gapczynski <mtgap@owncloud.com>
Sun, 19 May 2013 18:15:49 +0000 (14:15 -0400)
committerMichael Gapczynski <mtgap@owncloud.com>
Fri, 24 May 2013 00:40:13 +0000 (20:40 -0400)
Conflicts:
lib/files/cache/scanner.php

lib/files/cache/scanner.php
lib/files/filesystem.php
lib/files/view.php

index 32872eb226ea20cb9a74fef8e1b522fad4ed9948..594483e8be0704d82001ce10b7ef30cd82381a3d 100644 (file)
@@ -114,8 +114,8 @@ class Scanner {
                if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
                        \OC_DB::beginTransaction();
                        while ($file = readdir($dh)) {
-                               if (!$this->isIgnoredDir($file)) {
-                                       $child = ($path) ? $path . '/' . $file : $file;
+                               $child = ($path) ? $path . '/' . $file : $file;
+                               if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                                        $data = $this->scanFile($child, $recursive === self::SCAN_SHALLOW);
                                        if ($data) {
                                                if ($data['size'] === -1) {
@@ -149,18 +149,6 @@ class Scanner {
                return $size;
        }
 
-       /**
-        * @brief check if the directory should be ignored when scanning
-        * NOTE: the special directories . and .. would cause never ending recursion
-        * @param String $dir
-        * @return boolean
-        */
-       private function isIgnoredDir($dir) {
-               if ($dir === '.' || $dir === '..') {
-                       return true;
-               }
-               return false;
-       }
        /**
         * @brief check if the file should be ignored when scanning
         * NOTE: files with a '.part' extension are ignored as well!
index 9edbbf1b34b9d3fbe9a72811e4acc0f42d515df0..5570f91fe09301a0729dc23014e7739d8a4d580e 100644 (file)
@@ -422,6 +422,19 @@ class Filesystem {
                return (in_array($filename, $blacklist));
        }
 
+       /**
+        * @brief check if the directory should be ignored when scanning
+        * NOTE: the special directories . and .. would cause never ending recursion
+        * @param String $dir
+        * @return boolean
+        */
+       static public function isIgnoredDir($dir) {
+               if ($dir === '.' || $dir === '..') {
+                       return true;
+               }
+               return false;
+       }
+
        /**
         * following functions are equivalent to their php builtin equivalents for arguments/return values.
         */
index a738b8cac8a085d4d91360d03acb5147401b5a88..c7764c6095dc7a0678b809a18bb85f22cdf438b2 100644 (file)
@@ -372,11 +372,18 @@ class View {
                                                $result = false;
                                        }
                                } else {
-                                       $source = $this->fopen($path1 . $postFix1, 'r');
-                                       $target = $this->fopen($path2 . $postFix2, 'w');
-                                       list($count, $result) = \OC_Helper::streamCopy($source, $target);
-                                       list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
-                                       $storage1->unlink($internalPath1);
+                                       if ($this->is_dir($path1)) {
+                                               $result = $this->copy($path1, $path2);
+                                               if ($result === true) {
+                                                       $result = $this->deleteAll($path1);
+                                               }
+                                       } else {
+                                               $source = $this->fopen($path1 . $postFix1, 'r');
+                                               $target = $this->fopen($path2 . $postFix2, 'w');
+                                               list($count, $result) = \OC_Helper::streamCopy($source, $target);
+                                               list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
+                                               $storage1->unlink($internalPath1);
+                                       }
                                }
                                if ($this->fakeRoot == Filesystem::getRoot() && !Cache\Scanner::isPartialFile($path1)) {
                                        \OC_Hook::emit(
@@ -459,9 +466,18 @@ class View {
                                                $result = false;
                                        }
                                } else {
-                                       $source = $this->fopen($path1 . $postFix1, 'r');
-                                       $target = $this->fopen($path2 . $postFix2, 'w');
-                                       list($count, $result) = \OC_Helper::streamCopy($source, $target);
+                                       if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) {
+                                               $this->mkdir($path2);
+                                               while ($file = readdir($dh)) {
+                                                       if (!Filesystem::isIgnoredDir($file)) {
+                                                               $result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file);
+                                                       }
+                                               }
+                                       } else {
+                                               $source = $this->fopen($path1 . $postFix1, 'r');
+                                               $target = $this->fopen($path2 . $postFix2, 'w');
+                                               list($count, $result) = \OC_Helper::streamCopy($source, $target);
+                                       }
                                }
                                if ($this->fakeRoot == Filesystem::getRoot()) {
                                        \OC_Hook::emit(