diff options
author | Robin Appelman <robin@icewind.nl> | 2015-01-28 17:15:11 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2015-01-28 17:15:11 +0100 |
commit | 41382ef7fcc607203ab0586134a7c5c3ae6c7ce2 (patch) | |
tree | 3018a10d614c8a01af71fb45fbd391ca757f9739 | |
parent | 723f2a1cba27345e3cba2c43887a974813402299 (diff) | |
parent | a59612752e3b2829516833ea5b189df63ff49cd0 (diff) | |
download | nextcloud-server-41382ef7fcc607203ab0586134a7c5c3ae6c7ce2.tar.gz nextcloud-server-41382ef7fcc607203ab0586134a7c5c3ae6c7ce2.zip |
Merge pull request #13667 from owncloud/rename-always-update-cache
Update the cache when renaming even if we dont emit hooks
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 3 | ||||
-rw-r--r-- | lib/private/files/node/root.php | 2 | ||||
-rw-r--r-- | lib/private/files/view.php | 24 | ||||
-rw-r--r-- | tests/lib/files/node/integration.php | 4 |
4 files changed, 20 insertions, 13 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 4086bb1216d..0576be66b4b 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -167,6 +167,9 @@ class Trashbin { $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; try { $sizeOfAddedFiles = $view->filesize('/files/' . $file_path); + if ($view->file_exists($trashPath)) { + $view->unlink($trashPath); + } $view->rename('/files/' . $file_path, $trashPath); } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) { $sizeOfAddedFiles = false; diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php index 1dd4a3e378d..1834ef67bef 100644 --- a/lib/private/files/node/root.php +++ b/lib/private/files/node/root.php @@ -155,7 +155,7 @@ class Root extends Folder implements IRootFolder { * @param string $path * @throws \OCP\Files\NotFoundException * @throws \OCP\Files\NotPermittedException - * @return string + * @return \OCP\Files\Node */ public function get($path) { $path = $this->normalizePath($path); diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 096d8044b75..a2717ce4321 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -537,16 +537,18 @@ class View { if ($this->shouldEmitHooks()) { $this->emit_file_hooks_post($exists, $path2); } - } elseif ($this->shouldEmitHooks() && $result !== false) { + } elseif ($result !== false) { $this->updater->rename($path1, $path2); - \OC_Hook::emit( - Filesystem::CLASSNAME, - Filesystem::signal_post_rename, - array( - Filesystem::signal_param_oldpath => $this->getHookPath($path1), - Filesystem::signal_param_newpath => $this->getHookPath($path2) - ) - ); + if ($this->shouldEmitHooks($path1) and $this->shouldEmitHooks($path2)) { + \OC_Hook::emit( + Filesystem::CLASSNAME, + Filesystem::signal_post_rename, + array( + Filesystem::signal_param_oldpath => $this->getHookPath($path1), + Filesystem::signal_param_newpath => $this->getHookPath($path2) + ) + ); + } } return $result; } else { @@ -1315,7 +1317,7 @@ class View { $maxLen = min(PHP_MAXPATHLEN, 4000); // Check for the string length - performed using isset() instead of strlen() // because isset() is about 5x-40x faster. - if(isset($path[$maxLen])) { + if (isset($path[$maxLen])) { $pathLen = strlen($path); throw new \OCP\Files\InvalidPathException("Path length($pathLen) exceeds max path length($maxLen): $path"); } @@ -1351,7 +1353,7 @@ class View { * @return \OCP\Files\FileInfo */ private function getPartFileInfo($path) { - $mount = $this->getMount($path); + $mount = $this->getMount($path); $storage = $mount->getStorage(); $internalPath = $mount->getInternalPath($this->getAbsolutePath($path)); return new FileInfo( diff --git a/tests/lib/files/node/integration.php b/tests/lib/files/node/integration.php index d8c180cc844..456a4a0e287 100644 --- a/tests/lib/files/node/integration.php +++ b/tests/lib/files/node/integration.php @@ -80,7 +80,9 @@ class IntegrationTests extends \Test\TestCase { $this->assertEquals('text/plain', $file->getMimeType()); $this->assertEquals('qwerty', $file->getContent()); $this->assertFalse($this->root->nodeExists('/bar.txt')); - $file->move('/bar.txt'); + $target = $file->move('/bar.txt'); + $this->assertEquals($id, $target->getId()); + $this->assertEquals($id, $file->getId()); $this->assertFalse($this->root->nodeExists('/foo.txt')); $this->assertTrue($this->root->nodeExists('/bar.txt')); $this->assertEquals('bar.txt', $file->getName()); |