From e1f2a6df94af29864778a3ac286887ba51f19b04 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 5 Mar 2015 17:27:10 +0100 Subject: [PATCH] Allow setting the watcher policy as mount option --- lib/private/files/cache/watcher.php | 7 +++++++ lib/private/files/storage/common.php | 3 ++- tests/lib/files/view.php | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/private/files/cache/watcher.php b/lib/private/files/cache/watcher.php index f4572895b0..22c3fb202c 100644 --- a/lib/private/files/cache/watcher.php +++ b/lib/private/files/cache/watcher.php @@ -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 * diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index db66feb460..d7fff6e6e1 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -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; } diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 4ac014a92b..475383b5fe 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -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()); + } }