diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-10-26 15:07:11 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-11-03 18:23:22 +0100 |
commit | 4f2656993ed95fee486e56fa1032805104e1a1ab (patch) | |
tree | 1e570a97c11746dce4ecacbd0174e100f3fe75d6 /lib/private | |
parent | 0397871f7e205683b839faec99a723630ecdaf0a (diff) | |
download | nextcloud-server-4f2656993ed95fee486e56fa1032805104e1a1ab.tar.gz nextcloud-server-4f2656993ed95fee486e56fa1032805104e1a1ab.zip |
only lock in getFileInfo if we need to update the cache
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/view.php | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index a11df53705c..169bf59b20d 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1191,28 +1191,26 @@ class View { if ($storage) { $cache = $storage->getCache($internalPath); - try { - $this->lockFile($relativePath, ILockingProvider::LOCK_SHARED); - $data = $cache->get($internalPath); - $watcher = $storage->getWatcher($internalPath); + $data = $cache->get($internalPath); + $watcher = $storage->getWatcher($internalPath); - // if the file is not in the cache or needs to be updated, trigger the scanner and reload the data - if (!$data) { - if (!$storage->file_exists($internalPath)) { - $this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED); - return false; - } - $scanner = $storage->getScanner($internalPath); - $scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW); - $data = $cache->get($internalPath); - } else if (!Cache\Scanner::isPartialFile($internalPath) && $watcher->checkUpdate($internalPath, $data)) { - $this->updater->propagate($path); - $data = $cache->get($internalPath); + // if the file is not in the cache or needs to be updated, trigger the scanner and reload the data + if (!$data) { + $this->lockFile($relativePath, ILockingProvider::LOCK_SHARED); + if (!$storage->file_exists($internalPath)) { + $this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED); + return false; } + $scanner = $storage->getScanner($internalPath); + $scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW); + $data = $cache->get($internalPath); $this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED); - } catch (LockedException $e) { - // dont try to update the cache when the file is locked + } else if (!Cache\Scanner::isPartialFile($internalPath) && $watcher->needsUpdate($internalPath, $data)) { + $this->lockFile($relativePath, ILockingProvider::LOCK_SHARED); + $watcher->update($internalPath, $data); + $this->updater->propagate($path); $data = $cache->get($internalPath); + $this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED); } if ($data and isset($data['fileid'])) { |