diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-11-04 14:45:10 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-11-04 14:45:10 +0100 |
commit | c487f0f13823322d7290d90e37e20bf0c317efb5 (patch) | |
tree | 2df62c50363e84a9d43df4eaf1c4df00d98c1cd5 | |
parent | 0a56313ca445cfdcd02523fd97a248f539b7323a (diff) | |
download | nextcloud-server-c487f0f13823322d7290d90e37e20bf0c317efb5.tar.gz nextcloud-server-c487f0f13823322d7290d90e37e20bf0c317efb5.zip |
when a file is locked use old cache data
-rw-r--r-- | lib/private/files/view.php | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 57cd32cefe7..887b18530d7 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1194,23 +1194,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'])) { @@ -1278,22 +1282,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']; |