diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index 31a4a7c21e7c..2ddee57c7874 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -42,6 +42,9 @@ public function propagate($path, $time = null) { * @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 @@ public function rename($source, $target) { 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 704aabf2ad6a..54d8ff6b2ad3 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -945,4 +945,17 @@ public function testDeleteFailKeepCache() { $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')); + } }