Also propagate etag changes when the watcher finds a changed file
This commit is contained in:
parent
e345697cab
commit
d26a427f92
3 changed files with 38 additions and 0 deletions
5
lib/private/files/cache/updater.php
vendored
5
lib/private/files/cache/updater.php
vendored
|
@ -30,6 +30,11 @@ class Updater {
|
||||||
$this->propagator = new ChangePropagator($view);
|
$this->propagator = new ChangePropagator($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function propagate($path, $time = null) {
|
||||||
|
$this->propagator->addChange($path);
|
||||||
|
$this->propagator->propagateChanges($time);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the cache for $path
|
* Update the cache for $path
|
||||||
*
|
*
|
||||||
|
|
|
@ -903,6 +903,7 @@ class View {
|
||||||
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
|
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
|
||||||
$data = $cache->get($internalPath);
|
$data = $cache->get($internalPath);
|
||||||
} else if ($watcher->checkUpdate($internalPath, $data)) {
|
} else if ($watcher->checkUpdate($internalPath, $data)) {
|
||||||
|
$this->updater->propagate($path);
|
||||||
$data = $cache->get($internalPath);
|
$data = $cache->get($internalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,6 +975,7 @@ class View {
|
||||||
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
|
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
|
||||||
$data = $cache->get($internalPath);
|
$data = $cache->get($internalPath);
|
||||||
} else if ($watcher->checkUpdate($internalPath, $data)) {
|
} else if ($watcher->checkUpdate($internalPath, $data)) {
|
||||||
|
$this->updater->propagate($path);
|
||||||
$data = $cache->get($internalPath);
|
$data = $cache->get($internalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
namespace Test\Files;
|
namespace Test\Files;
|
||||||
|
|
||||||
use OC\Files\Cache\Watcher;
|
use OC\Files\Cache\Watcher;
|
||||||
|
use OC\Files\Storage\Temporary;
|
||||||
|
|
||||||
class TemporaryNoTouch extends \OC\Files\Storage\Temporary {
|
class TemporaryNoTouch extends \OC\Files\Storage\Temporary {
|
||||||
public function touch($path, $mtime = null) {
|
public function touch($path, $mtime = null) {
|
||||||
|
@ -652,6 +653,36 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertSame($info['etag'], $info2['etag']);
|
$this->assertSame($info['etag'], $info2['etag']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWatcherEtagCrossStorage() {
|
||||||
|
$storage1 = new Temporary(array());
|
||||||
|
$storage2 = new Temporary(array());
|
||||||
|
$scanner1 = $storage1->getScanner();
|
||||||
|
$scanner2 = $storage2->getScanner();
|
||||||
|
$storage1->mkdir('sub');
|
||||||
|
\OC\Files\Filesystem::mount($storage1, array(), '/test/');
|
||||||
|
\OC\Files\Filesystem::mount($storage2, array(), '/test/sub/storage');
|
||||||
|
|
||||||
|
$past = time() - 100;
|
||||||
|
$storage2->file_put_contents('test.txt', 'foobar');
|
||||||
|
$scanner1->scan('');
|
||||||
|
$scanner2->scan('');
|
||||||
|
$view = new \OC\Files\View('');
|
||||||
|
|
||||||
|
$storage2->getWatcher('')->setPolicy(Watcher::CHECK_ALWAYS);
|
||||||
|
|
||||||
|
$oldFileInfo = $view->getFileInfo('/test/sub/storage/test.txt');
|
||||||
|
$oldFolderInfo = $view->getFileInfo('/test');
|
||||||
|
|
||||||
|
$storage2->getCache()->update($oldFileInfo->getId(), array(
|
||||||
|
'storage_mtime' => $past
|
||||||
|
));
|
||||||
|
|
||||||
|
$view->getFileInfo('/test/sub/storage/test.txt');
|
||||||
|
$newFolderInfo = $view->getFileInfo('/test');
|
||||||
|
|
||||||
|
$this->assertNotEquals($newFolderInfo->getEtag(), $oldFolderInfo->getEtag());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider absolutePathProvider
|
* @dataProvider absolutePathProvider
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue