summaryrefslogtreecommitdiffstats
path: root/lib/files
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-05-19 14:15:49 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2013-05-19 14:15:49 -0400
commit41e2d64c86fffc3e507a1ad0788bcb498db2c640 (patch)
tree20a1cea6e03c1efb72c0a33bee7d9517e1c5c711 /lib/files
parent0f314c14048b85a639ceb0c29e26f47e139e96c5 (diff)
downloadnextcloud-server-41e2d64c86fffc3e507a1ad0788bcb498db2c640.tar.gz
nextcloud-server-41e2d64c86fffc3e507a1ad0788bcb498db2c640.zip
Add support for copying/moving folders between storages, move isIgnoredDir() to Filesystem
Diffstat (limited to 'lib/files')
-rw-r--r--lib/files/cache/scanner.php14
-rw-r--r--lib/files/filesystem.php13
-rw-r--r--lib/files/view.php32
3 files changed, 38 insertions, 21 deletions
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index 661bc486330..0b1947f17ca 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -115,7 +115,7 @@ class Scanner {
\OC_DB::beginTransaction();
while ($file = readdir($dh)) {
$child = ($path) ? $path . '/' . $file : $file;
- if (!$this->isIgnoredDir($file)) {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
$data = $this->scanFile($child, $recursive === self::SCAN_SHALLOW);
if ($data) {
if ($data['size'] === -1) {
@@ -150,18 +150,6 @@ class Scanner {
}
/**
- * @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!
* prevents unfinished put requests to be scanned
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index d60d430d77c..99d87011df2 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -454,6 +454,19 @@ class Filesystem {
}
/**
+ * @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.
*/
static public function mkdir($path) {
diff --git a/lib/files/view.php b/lib/files/view.php
index f35e1e3dc16..875a6c1a1f8 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -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(