Skip to content
Snippets Groups Projects
Commit 41e2d64c authored by Michael Gapczynski's avatar Michael Gapczynski
Browse files

Add support for copying/moving folders between storages, move isIgnoredDir() to Filesystem

parent 0f314c14
No related branches found
No related tags found
No related merge requests found
...@@ -115,7 +115,7 @@ class Scanner { ...@@ -115,7 +115,7 @@ class Scanner {
\OC_DB::beginTransaction(); \OC_DB::beginTransaction();
while ($file = readdir($dh)) { while ($file = readdir($dh)) {
$child = ($path) ? $path . '/' . $file : $file; $child = ($path) ? $path . '/' . $file : $file;
if (!$this->isIgnoredDir($file)) { if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
$data = $this->scanFile($child, $recursive === self::SCAN_SHALLOW); $data = $this->scanFile($child, $recursive === self::SCAN_SHALLOW);
if ($data) { if ($data) {
if ($data['size'] === -1) { if ($data['size'] === -1) {
...@@ -149,18 +149,6 @@ class Scanner { ...@@ -149,18 +149,6 @@ class Scanner {
return $size; 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 * @brief check if the file should be ignored when scanning
* NOTE: files with a '.part' extension are ignored as well! * NOTE: files with a '.part' extension are ignored as well!
......
...@@ -453,6 +453,19 @@ class Filesystem { ...@@ -453,6 +453,19 @@ class Filesystem {
return (in_array($filename, $blacklist)); 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. * following functions are equivalent to their php builtin equivalents for arguments/return values.
*/ */
......
...@@ -372,11 +372,18 @@ class View { ...@@ -372,11 +372,18 @@ class View {
$result = false; $result = false;
} }
} else { } else {
$source = $this->fopen($path1 . $postFix1, 'r'); if ($this->is_dir($path1)) {
$target = $this->fopen($path2 . $postFix2, 'w'); $result = $this->copy($path1, $path2);
list($count, $result) = \OC_Helper::streamCopy($source, $target); if ($result === true) {
list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); $result = $this->deleteAll($path1);
$storage1->unlink($internalPath1); }
} 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)) { if ($this->fakeRoot == Filesystem::getRoot() && !Cache\Scanner::isPartialFile($path1)) {
\OC_Hook::emit( \OC_Hook::emit(
...@@ -459,9 +466,18 @@ class View { ...@@ -459,9 +466,18 @@ class View {
$result = false; $result = false;
} }
} else { } else {
$source = $this->fopen($path1 . $postFix1, 'r'); if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) {
$target = $this->fopen($path2 . $postFix2, 'w'); $this->mkdir($path2);
list($count, $result) = \OC_Helper::streamCopy($source, $target); 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()) { if ($this->fakeRoot == Filesystem::getRoot()) {
\OC_Hook::emit( \OC_Hook::emit(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment