[Pkg-owncloud-commits] [owncloud] 15/69: when a file is locked use old cache data

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 7fb5092a3920c5f6c5c36f731e5481db1e502cae
Author: Robin Appelman <icewind at owncloud.com>
Date:   Wed Nov 4 14:45:10 2015 +0100

    when a file is locked use old cache data
---
 lib/private/files/view.php | 66 ++++++++++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 29 deletions(-)

diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index c1bbbfa..a89f802 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1190,23 +1190,27 @@ class View {
 			$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) {
-				$this->lockFile($relativePath, ILockingProvider::LOCK_SHARED);
-				if (!$storage->file_exists($internalPath)) {
+			try {
+				// 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);
+				} 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);
-					return false;
 				}
-				$scanner = $storage->getScanner($internalPath);
-				$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
-				$data = $cache->get($internalPath);
-				$this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED);
-			} 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);
+			} catch (LockedException $e) {
+				// if the file is locked we just use the old cache info
 			}
 
 			if ($data and isset($data['fileid'])) {
@@ -1274,22 +1278,26 @@ class View {
 
 			$data = $cache->get($internalPath);
 			$watcher = $storage->getWatcher($internalPath);
-			if (!$data or $data['size'] === -1) {
-				$this->lockFile($directory, ILockingProvider::LOCK_SHARED);
-				if (!$storage->file_exists($internalPath)) {
+			try {
+				if (!$data or $data['size'] === -1) {
+					$this->lockFile($directory, ILockingProvider::LOCK_SHARED);
+					if (!$storage->file_exists($internalPath)) {
+						$this->unlockFile($directory, ILockingProvider::LOCK_SHARED);
+						return array();
+					}
+					$scanner = $storage->getScanner($internalPath);
+					$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
+					$data = $cache->get($internalPath);
+					$this->unlockFile($directory, ILockingProvider::LOCK_SHARED);
+				} else if ($watcher->needsUpdate($internalPath, $data)) {
+					$this->lockFile($directory, ILockingProvider::LOCK_SHARED);
+					$watcher->update($internalPath, $data);
+					$this->updater->propagate($path);
+					$data = $cache->get($internalPath);
 					$this->unlockFile($directory, ILockingProvider::LOCK_SHARED);
-					return array();
 				}
-				$scanner = $storage->getScanner($internalPath);
-				$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
-				$data = $cache->get($internalPath);
-				$this->unlockFile($directory, ILockingProvider::LOCK_SHARED);
-			} else if ($watcher->needsUpdate($internalPath, $data)) {
-				$this->lockFile($directory, ILockingProvider::LOCK_SHARED);
-				$watcher->update($internalPath, $data);
-				$this->updater->propagate($path);
-				$data = $cache->get($internalPath);
-				$this->unlockFile($directory, ILockingProvider::LOCK_SHARED);
+			} catch (LockedException $e) {
+				// if the file is locked we just use the old cache info
 			}
 
 			$folderId = $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