summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/files/storage/common.php7
-rw-r--r--lib/files/storage/storage.php5
-rw-r--r--lib/files/view.php4
-rw-r--r--tests/lib/files/cache/watcher.php14
4 files changed, 21 insertions, 9 deletions
diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php
index 3cf960d05df..ab167f28646 100644
--- a/lib/files/storage/common.php
+++ b/lib/files/storage/common.php
@@ -250,6 +250,13 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
/**
+ * @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
* @return string uid or false
diff --git a/lib/files/storage/storage.php b/lib/files/storage/storage.php
index 73dcb8fe36b..b603381dc90 100644
--- a/lib/files/storage/storage.php
+++ b/lib/files/storage/storage.php
@@ -70,6 +70,11 @@ interface Storage{
public function getPermissionsCache();
/**
+ * @return \OC\Files\Cache\Watcher
+ */
+ public function getWatcher();
+
+ /**
* get the ETag for a file or folder
*
* @param string $path
diff --git a/lib/files/view.php b/lib/files/view.php
index 592c484a21c..d3f93d39f5a 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -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);
}
diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php
index 07c8ac3640c..e8a1689cab0 100644
--- a/tests/lib/files/cache/watcher.php
+++ b/tests/lib/files/cache/watcher.php
@@ -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'));
}