From 9738fae3cf1ad18593d21eb62e138e00c01f5f36 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 10 Feb 2013 12:44:27 +0100 Subject: Emulate touch() for backends that don't support it --- lib/files/view.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/files/view.php') diff --git a/lib/files/view.php b/lib/files/view.php index 1a234228eab..69e2f1ad349 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -242,7 +242,11 @@ class View { if (!is_null($mtime) and !is_numeric($mtime)) { $mtime = strtotime($mtime); } - return $this->basicOperation('touch', $path, array('write'), $mtime); + $result = $this->basicOperation('touch', $path, array('write'), $mtime); + if (!$result) { //if native touch fails, we emulate it by changing the mtime in the cache + $this->putFileInfo($path, array('mtime' => $mtime)); + } + return true; } public function file_get_contents($path) { @@ -917,11 +921,11 @@ class View { } /** - * Get the owner for a file or folder - * - * @param string $path - * @return string - */ + * Get the owner for a file or folder + * + * @param string $path + * @return string + */ public function getOwner($path) { return $this->basicOperation('getOwner', $path); } -- cgit v1.2.3 From 25ff32db6bec0992b0fac18b04345aa5e99f4ea1 Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Tue, 23 Apr 2013 22:20:31 +0200 Subject: Added post proxy for getFileInfo. This is needed for WebDAV and FileSize @samtuke and @schiesbn you guys know a better solution? --- lib/files/view.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/files/view.php') diff --git a/lib/files/view.php b/lib/files/view.php index f607bb59aac..bd4812f8f81 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -724,6 +724,9 @@ class View { $data['permissions'] = $permissions; } } + + $data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data); + return $data; } -- cgit v1.2.3 From 672d177f10e44581ecc9f37844681afaa06c0272 Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Thu, 25 Apr 2013 22:43:15 +0200 Subject: added post rename proxy --- lib/files/view.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/files/view.php') diff --git a/lib/files/view.php b/lib/files/view.php index bd4812f8f81..d0fc5910e6c 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -362,6 +362,7 @@ class View { list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2); if ($storage) { $result = $storage->rename($internalPath1, $internalPath2); + \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2); } else { $result = false; } -- 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/view.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 fc5bce1f76a3a67a4ac9095d15441e363dfd03d1 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sun, 19 May 2013 15:04:41 -0400 Subject: Fix undefined variable for copying empty folders --- lib/files/view.php | 2 +- tests/lib/files/view.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/files/view.php') diff --git a/lib/files/view.php b/lib/files/view.php index 875a6c1a1f8..8a37a0bcc62 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -467,7 +467,7 @@ class View { } } else { if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) { - $this->mkdir($path2); + $result = $this->mkdir($path2); while ($file = readdir($dh)) { if (!Filesystem::isIgnoredDir($file)) { $result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file); diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 554bc7291ad..a51d99e793d 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -235,9 +235,12 @@ class View extends \PHPUnit_Framework_TestCase { \OC\Files\Filesystem::mount($storage2, array(), '/substorage'); $rootView = new \OC\Files\View(''); + $rootView->mkdir('substorage/emptyfolder'); $rootView->copy('substorage', 'anotherfolder'); $this->assertTrue($rootView->is_dir('/anotherfolder')); $this->assertTrue($rootView->is_dir('/substorage')); + $this->assertTrue($rootView->is_dir('/anotherfolder/emptyfolder')); + $this->assertTrue($rootView->is_dir('/substorage/emptyfolder')); $this->assertTrue($rootView->file_exists('/anotherfolder/foo.txt')); $this->assertTrue($rootView->file_exists('/anotherfolder/foo.png')); $this->assertTrue($rootView->file_exists('/anotherfolder/folder/bar.txt')); -- cgit v1.2.3 From 3b6d850e592bbc6db9d67d25ee700c0730c84376 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Thu, 23 May 2013 10:23:16 -0400 Subject: Switch to calling deleteAll via storage to avoid emitting delete hook --- lib/files/view.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/files/view.php') diff --git a/lib/files/view.php b/lib/files/view.php index 8a37a0bcc62..d0d473766cc 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -375,7 +375,8 @@ class View { if ($this->is_dir($path1)) { $result = $this->copy($path1, $path2); if ($result === true) { - $result = $this->deleteAll($path1); + list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); + $result = $storage1->deleteAll($internalPath1); } } else { $source = $this->fopen($path1 . $postFix1, 'r'); -- cgit v1.2.3