From 1384bf5066c38f09e8c6995d26aa5c03dd63ec2c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 26 Feb 2016 12:48:56 +0100 Subject: use the default view for propagation if possible --- lib/private/files/cache/updater.php | 33 ++++++++++++++++++++++++++------- lib/private/files/view.php | 3 ++- 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index 2de0c8fe067..c687d190873 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -24,6 +24,7 @@ */ namespace OC\Files\Cache; +use OC\Files\View; /** * Update the cache and propagate changes @@ -47,12 +48,30 @@ class Updater { */ protected $propagator; + /** + * @var null|View + */ + protected $propagatorView; + /** * @param \OC\Files\View $view the view the updater works on, usually the view of the logged in user + * @param View | null $userView */ - public function __construct($view) { + public function __construct(View $view, $userView = null) { $this->view = $view; - $this->propagator = new ChangePropagator($view); + + // use the userview if the view is a subfolder + if ($userView && $userView->getRelativePath($view->getRoot())) { + $this->propagatorView = $userView; + $this->propagator = new ChangePropagator($userView); + } else { + $this->propagatorView = $view; + $this->propagator = new ChangePropagator($view); + } + } + + protected function getPropagatorPath($path) { + return $this->propagatorView->getRelativePath($this->view->getAbsolutePath($path)); } /** @@ -88,7 +107,7 @@ class Updater { if (Scanner::isPartialFile($path)) { return; } - $this->propagator->addChange($path); + $this->propagator->addChange($this->getPropagatorPath($path)); $this->propagator->propagateChanges($time); } @@ -108,7 +127,7 @@ class Updater { */ list($storage, $internalPath) = $this->view->resolvePath($path); if ($storage) { - $this->propagator->addChange($path); + $this->propagator->addChange($this->getPropagatorPath($path)); $cache = $storage->getCache($internalPath); $scanner = $storage->getScanner($internalPath); $data = $scanner->scan($internalPath, Scanner::SCAN_SHALLOW, -1, false); @@ -137,7 +156,7 @@ class Updater { if ($parent === '.') { $parent = ''; } - $this->propagator->addChange($path); + $this->propagator->addChange($this->getPropagatorPath($path)); $cache = $storage->getCache($internalPath); $cache->remove($internalPath); $cache->correctFolderSize($parent); @@ -193,8 +212,8 @@ class Updater { $targetCache->correctFolderSize($targetInternalPath); $this->correctParentStorageMtime($sourceStorage, $sourceInternalPath); $this->correctParentStorageMtime($targetStorage, $targetInternalPath); - $this->propagator->addChange($source); - $this->propagator->addChange($target); + $this->propagator->addChange($this->getPropagatorPath($source)); + $this->propagator->addChange($this->getPropagatorPath($target)); $this->propagator->propagateChanges(); } } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index a89f802e3d1..4f3fb5be582 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -95,7 +95,8 @@ class View { } $this->fakeRoot = $root; - $this->updater = new Updater($this); + + $this->updater = new Updater($this, Filesystem::getView()); $this->lockingProvider = \OC::$server->getLockingProvider(); $this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider); } -- cgit v1.2.3