diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-06-02 15:17:00 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-06-02 15:24:08 +0200 |
commit | e002ff60658f675dba038aca8f682080b71d6ece (patch) | |
tree | 6093a99495cfc614bb7a4105bef9183a98637c2b /lib/private/files/utils/scanner.php | |
parent | 0158788a2a07a9eef9689c9d252659eedf852083 (diff) | |
download | nextcloud-server-e002ff60658f675dba038aca8f682080b71d6ece.tar.gz nextcloud-server-e002ff60658f675dba038aca8f682080b71d6ece.zip |
propagate changes in the scanner
Diffstat (limited to 'lib/private/files/utils/scanner.php')
-rw-r--r-- | lib/private/files/utils/scanner.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php index a802a8fcb8b..1bb3e694c96 100644 --- a/lib/private/files/utils/scanner.php +++ b/lib/private/files/utils/scanner.php @@ -8,6 +8,8 @@ namespace OC\Files\Utils; +use OC\Files\View; +use OC\Files\Cache\ChangePropagator; use OC\Files\Filesystem; use OC\Hooks\PublicEmitter; @@ -27,10 +29,16 @@ class Scanner extends PublicEmitter { private $user; /** + * @var \OC\Files\Cache\ChangePropagator + */ + protected $propagator; + + /** * @param string $user */ public function __construct($user) { $this->user = $user; + $this->propagator = new ChangePropagator(new View('')); } /** @@ -67,6 +75,15 @@ class Scanner extends PublicEmitter { $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) { $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); }); + + // propagate etag and mtimes when files are changed or removed + $propagator = $this->propagator; + $propagatorListener = function ($path) use ($mount, $propagator) { + $fullPath = Filesystem::normalizePath($mount->getMountPoint() . $path); + $propagator->addChange($fullPath); + }; + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', $propagatorListener); + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', $propagatorListener); } /** @@ -82,6 +99,7 @@ class Scanner extends PublicEmitter { $this->attachListener($mount); $scanner->backgroundScan(); } + $this->propagator->propagateChanges(time()); } /** @@ -95,8 +113,9 @@ class Scanner extends PublicEmitter { } $scanner = $mount->getStorage()->getScanner(); $this->attachListener($mount); - $scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG); + $scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); } + $this->propagator->propagateChanges(time()); } } |