mirror of
https://github.com/nextcloud/server.git
synced 2025-03-17 09:43:16 +00:00
Allow setting the watcher policy as mount option
This commit is contained in:
parent
7adda88786
commit
e1f2a6df94
3 changed files with 18 additions and 1 deletions
7
lib/private/files/cache/watcher.php
vendored
7
lib/private/files/cache/watcher.php
vendored
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue