Allow setting the watcher policy as mount option

This commit is contained in:
Robin Appelman 2015-03-05 17:27:10 +01:00
parent 7adda88786
commit e1f2a6df94
3 changed files with 18 additions and 1 deletions

View File

@ -51,6 +51,13 @@ class Watcher {
$this->watchPolicy = $policy;
}
/**
* @return int either \OC\Files\Cache\Watcher::CHECK_NEVER, \OC\Files\Cache\Watcher::CHECK_ONCE, \OC\Files\Cache\Watcher::CHECK_ALWAYS
*/
public function getPolicy() {
return $this->watchPolicy;
}
/**
* check $path for updates
*

View File

@ -331,7 +331,8 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
if (!isset($this->watcher)) {
$this->watcher = new Watcher($storage);
$this->watcher->setPolicy(\OC::$server->getConfig()->getSystemValue('filesystem_check_changes', Watcher::CHECK_ONCE));
$globalPolicy = \OC::$server->getConfig()->getSystemValue('filesystem_check_changes', Watcher::CHECK_ONCE);
$this->watcher->setPolicy($this->getMountOption('filesystem_check_changes', $globalPolicy));
}
return $this->watcher;
}

View File

@ -985,4 +985,13 @@ class View extends \Test\TestCase {
$storage = $mount->getStorage();
$this->assertEquals($storage->getMountOption('foo'), 'bar');
}
public function testSetMountOptionsWatcherPolicy() {
$mount = new MountPoint('\OC\Files\Storage\Temporary', '/asd/', [[]], Filesystem::getLoader(), ['filesystem_check_changes' => Watcher::CHECK_NEVER]);
Filesystem::getMountManager()->addMount($mount);
/** @var \OC\Files\Storage\Common $storage */
$storage = $mount->getStorage();
$watcher = $storage->getWatcher();
$this->assertEquals(Watcher::CHECK_NEVER, $watcher->getPolicy());
}
}