[Pkg-owncloud-commits] [owncloud] 13/69: only lock in getFileInfo if we need to update the cache

David Prévot taffit at moszumanska.debian.org
Wed Nov 11 02:04:00 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 7d9f190079ef99eaba9560846c0318e6019c8c3c
Author: Robin Appelman <icewind at owncloud.com>
Date:   Mon Oct 26 15:07:11 2015 +0100

    only lock in getFileInfo if we need to update the cache
---
 lib/private/files/view.php | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 73fc937..b4c611d 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1187,28 +1187,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'])) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list