From 807740a07a5385b0761aa23128f859a203e8b71a Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Wed, 15 May 2013 10:19:38 +0200 Subject: fix for losing mount point "/" --- lib/files/filesystem.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/files/filesystem.php') diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index eadd8a93faf..d60d430d77c 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -222,7 +222,10 @@ class Filesystem { return false; } self::$defaultInstance = new View($root); - self::$mounts = new Mount\Manager(); + + if(!self::$mounts) { + self::$mounts = new Mount\Manager(); + } //load custom mount config self::initMountPoints($user); -- cgit v1.2.3 From c50bf3e3c54ccbad6b58538fb131924d4f0ff3d7 Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Wed, 15 May 2013 10:19:38 +0200 Subject: fix for losing mount point "/" --- lib/files/filesystem.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/files/filesystem.php') diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index eadd8a93faf..d60d430d77c 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -222,7 +222,10 @@ class Filesystem { return false; } self::$defaultInstance = new View($root); - self::$mounts = new Mount\Manager(); + + if(!self::$mounts) { + self::$mounts = new Mount\Manager(); + } //load custom mount config self::initMountPoints($user); -- cgit v1.2.3 From 41e2d64c86fffc3e507a1ad0788bcb498db2c640 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sun, 19 May 2013 14:15:49 -0400 Subject: Add support for copying/moving folders between storages, move isIgnoredDir() to Filesystem --- lib/files/cache/scanner.php | 14 +------------- lib/files/filesystem.php | 13 +++++++++++++ lib/files/view.php | 32 ++++++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 21 deletions(-) (limited to 'lib/files/filesystem.php') 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) { @@ -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! 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 @@ -453,6 +453,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. */ 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( -- cgit v1.2.3 From 079f918d5ca0d242e77717aaeac82bcf011dc745 Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Sun, 19 May 2013 22:30:03 +0200 Subject: fix for webdav and wrong reference for findByStorageId --- lib/files/cache/backgroundwatcher.php | 2 +- lib/files/filesystem.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/files/filesystem.php') diff --git a/lib/files/cache/backgroundwatcher.php b/lib/files/cache/backgroundwatcher.php index 7549745e7d7..b5770d0582b 100644 --- a/lib/files/cache/backgroundwatcher.php +++ b/lib/files/cache/backgroundwatcher.php @@ -30,7 +30,7 @@ class BackgroundWatcher { return; } list($storageId, $internalPath) = $cacheItem; - $mounts = Mount::findByStorageId($storageId); + $mounts = Mount\Manager::findByStorageId($storageId); if (count($mounts) === 0) { //if the storage we need isn't mounted on default, try to find a user that has access to the storage diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index d60d430d77c..d0cac9dc1d3 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -236,7 +236,9 @@ class Filesystem { } static public function initMounts(){ - self::$mounts = new Mount\Manager(); + if(!self::$mounts) { + self::$mounts = new Mount\Manager(); + } } /** -- cgit v1.2.3 From b3b6738d599480fc9bf40a53313598c4766571fb Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Mon, 20 May 2013 01:47:35 +0200 Subject: Revert "fix for webdav and wrong reference for findByStorageId" This reverts commit 079f918d5ca0d242e77717aaeac82bcf011dc745. --- lib/files/cache/backgroundwatcher.php | 2 +- lib/files/filesystem.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/files/filesystem.php') diff --git a/lib/files/cache/backgroundwatcher.php b/lib/files/cache/backgroundwatcher.php index b5770d0582b..7549745e7d7 100644 --- a/lib/files/cache/backgroundwatcher.php +++ b/lib/files/cache/backgroundwatcher.php @@ -30,7 +30,7 @@ class BackgroundWatcher { return; } list($storageId, $internalPath) = $cacheItem; - $mounts = Mount\Manager::findByStorageId($storageId); + $mounts = Mount::findByStorageId($storageId); if (count($mounts) === 0) { //if the storage we need isn't mounted on default, try to find a user that has access to the storage diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index d0cac9dc1d3..d60d430d77c 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -236,9 +236,7 @@ class Filesystem { } static public function initMounts(){ - if(!self::$mounts) { - self::$mounts = new Mount\Manager(); - } + self::$mounts = new Mount\Manager(); } /** -- cgit v1.2.3 From 58a8d67a9b3c48567bcc40cc02444311c6773275 Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Mon, 20 May 2013 01:57:16 +0200 Subject: fix for webdav because initMounts() is triggered twice so we lost the root path --- lib/files/filesystem.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/files/filesystem.php') diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index d60d430d77c..d0cac9dc1d3 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -236,7 +236,9 @@ class Filesystem { } static public function initMounts(){ - self::$mounts = new Mount\Manager(); + if(!self::$mounts) { + self::$mounts = new Mount\Manager(); + } } /** -- cgit v1.2.3