Skip to content
Snippets Groups Projects
Commit b41189de authored by Robin Appelman's avatar Robin Appelman
Browse files

Cache: allow storage backends to overwrite Watcher

parent f2ca7023
No related branches found
No related tags found
No related merge requests found
......@@ -249,6 +249,13 @@ abstract class Common implements \OC\Files\Storage\Storage {
return new \OC\Files\Cache\Permissions($this);
}
/**
* @return \OC\Files\Cache\Watcher
*/
public function getWatcher(){
return new \OC\Files\Cache\Watcher($this);
}
/**
* get the owner of a path
* @param string $path The path to get the owner
......
......@@ -69,6 +69,11 @@ interface Storage{
*/
public function getPermissionsCache();
/**
* @return \OC\Files\Cache\Watcher
*/
public function getWatcher();
/**
* get the ETag for a file or folder
*
......
......@@ -685,7 +685,7 @@ class View {
$scanner = $storage->getScanner();
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
} else {
$watcher = new \OC\Files\Cache\Watcher($storage);
$watcher = $storage->getWatcher();
$watcher->checkUpdate($internalPath);
}
......@@ -733,7 +733,7 @@ class View {
$scanner = $storage->getScanner();
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
} else {
$watcher = new \OC\Files\Cache\Watcher($storage);
$watcher = $storage->getWatcher();
$watcher->checkUpdate($internalPath);
}
......
......@@ -32,7 +32,7 @@ class Watcher extends \PHPUnit_Framework_TestCase {
function testWatcher() {
$storage = $this->getTestStorage();
$cache = $storage->getCache();
$updater = new \OC\Files\Cache\Watcher($storage);
$updater = $storage->getWatcher();
//set the mtime to the past so it can detect an mtime change
$cache->put('', array('mtime' => 10));
......@@ -66,16 +66,16 @@ class Watcher extends \PHPUnit_Framework_TestCase {
public function testFileToFolder() {
$storage = $this->getTestStorage();
$cache = $storage->getCache();
$updater = new \OC\Files\Cache\Watcher($storage);
$updater = $storage->getWatcher();
//set the mtime to the past so it can detect an mtime change
$cache->put('', array('mtime' => 10));
$storage->unlink('foo.txt');
$storage->rename('folder','foo.txt');
$storage->rename('folder', 'foo.txt');
$updater->checkUpdate('');
$entry= $cache->get('foo.txt');
$entry = $cache->get('foo.txt');
$this->assertEquals(-1, $entry['size']);
$this->assertEquals('httpd/unix-directory', $entry['mimetype']);
$this->assertFalse($cache->inCache('folder'));
......@@ -83,16 +83,16 @@ class Watcher extends \PHPUnit_Framework_TestCase {
$storage = $this->getTestStorage();
$cache = $storage->getCache();
$updater = new \OC\Files\Cache\Watcher($storage);
$updater = $storage->getWatcher();
//set the mtime to the past so it can detect an mtime change
$cache->put('foo.txt', array('mtime' => 10));
$storage->unlink('foo.txt');
$storage->rename('folder','foo.txt');
$storage->rename('folder', 'foo.txt');
$updater->checkUpdate('foo.txt');
$entry= $cache->get('foo.txt');
$entry = $cache->get('foo.txt');
$this->assertEquals('httpd/unix-directory', $entry['mimetype']);
$this->assertTrue($cache->inCache('foo.txt/bar.txt'));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment