[Pkg-owncloud-commits] [owncloud] 85/95: Fix cache update when doing a rename that overwrites the target

David Prévot taffit at moszumanska.debian.org
Wed Mar 11 15:49:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.0.1
in repository owncloud.

commit a79602114327e06b91dee4200daac2c50e078b39
Author: Robin Appelman <icewind at owncloud.com>
Date:   Fri Feb 27 14:26:52 2015 +0100

    Fix cache update when doing a rename that overwrites the target
---
 lib/private/files/cache/updater.php |  6 ++++++
 tests/lib/files/view.php            | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index 31a4a7c..2ddee57 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -42,6 +42,9 @@ class Updater {
 	 * @param int $time
 	 */
 	public function update($path, $time = null) {
+		if (Scanner::isPartialFile($path)) {
+			return;
+		}
 		/**
 		 * @var \OC\Files\Storage\Storage $storage
 		 * @var string $internalPath
@@ -104,6 +107,9 @@ class Updater {
 		if ($sourceStorage && $targetStorage) {
 			if ($sourceStorage === $targetStorage) {
 				$cache = $sourceStorage->getCache($sourceInternalPath);
+				if ($cache->inCache($targetInternalPath)) {
+					$cache->remove($targetInternalPath);
+				}
 				$cache->move($sourceInternalPath, $targetInternalPath);
 
 				if (pathinfo($sourceInternalPath, PATHINFO_EXTENSION) !== pathinfo($targetInternalPath, PATHINFO_EXTENSION)) {
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 704aabf..54d8ff6 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -945,4 +945,17 @@ class View extends \Test\TestCase {
 		$this->assertFalse($view->unlink('foo.txt'));
 		$this->assertTrue($cache->inCache('foo.txt'));
 	}
+
+	public function testRenameOverWrite() {
+		$storage = new Temporary(array());
+		$scanner = $storage->getScanner();
+		$storage->mkdir('sub');
+		$storage->mkdir('foo');
+		$storage->file_put_contents('foo.txt', 'asd');
+		$storage->file_put_contents('foo/bar.txt', 'asd');
+		$scanner->scan('');
+		\OC\Files\Filesystem::mount($storage, array(), '/test/');
+		$view = new \OC\Files\View('');
+		$this->assertTrue($view->rename('/test/foo.txt', '/test/foo/bar.txt'));
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list