Merge pull request #14575 from owncloud/cache-rename-overwrite
Fix cache update when doing a rename that overwrites the target
This commit is contained in:
commit
b4dfd043d7
|
@ -45,7 +45,7 @@ class Updater {
|
||||||
* @param int $time
|
* @param int $time
|
||||||
*/
|
*/
|
||||||
public function update($path, $time = null) {
|
public function update($path, $time = null) {
|
||||||
if(Scanner::isPartialFile($path)) {
|
if (Scanner::isPartialFile($path)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -116,6 +116,9 @@ class Updater {
|
||||||
if ($sourceStorage && $targetStorage) {
|
if ($sourceStorage && $targetStorage) {
|
||||||
if ($sourceStorage === $targetStorage) {
|
if ($sourceStorage === $targetStorage) {
|
||||||
$cache = $sourceStorage->getCache($sourceInternalPath);
|
$cache = $sourceStorage->getCache($sourceInternalPath);
|
||||||
|
if ($cache->inCache($targetInternalPath)) {
|
||||||
|
$cache->remove($targetInternalPath);
|
||||||
|
}
|
||||||
$cache->move($sourceInternalPath, $targetInternalPath);
|
$cache->move($sourceInternalPath, $targetInternalPath);
|
||||||
|
|
||||||
if (pathinfo($sourceInternalPath, PATHINFO_EXTENSION) !== pathinfo($targetInternalPath, PATHINFO_EXTENSION)) {
|
if (pathinfo($sourceInternalPath, PATHINFO_EXTENSION) !== pathinfo($targetInternalPath, PATHINFO_EXTENSION)) {
|
||||||
|
|
|
@ -962,4 +962,17 @@ class View extends \Test\TestCase {
|
||||||
public function testConstructDirectoryTraversalException($root) {
|
public function testConstructDirectoryTraversalException($root) {
|
||||||
new \OC\Files\View($root);
|
new \OC\Files\View($root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue