aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-10-26 15:08:17 +0100
committerRobin Appelman <icewind@owncloud.com>2015-11-03 18:23:22 +0100
commitfc7f7e5c37a544b5a92c8415e7dfc6c47282765c (patch)
tree3cd3c15c54356bf9bf0a700aeb0d6251388670c5 /lib
parent4f2656993ed95fee486e56fa1032805104e1a1ab (diff)
downloadnextcloud-server-fc7f7e5c37a544b5a92c8415e7dfc6c47282765c.tar.gz
nextcloud-server-fc7f7e5c37a544b5a92c8415e7dfc6c47282765c.zip
only lock in getDirectoryContent if we need to update the cache
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/view.php38
1 files changed, 17 insertions, 21 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 169bf59b20d..d9b9db03d91 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1276,33 +1276,29 @@ class View {
*/
$files = array();
- try {
+ $data = $cache->get($internalPath);
+ $watcher = $storage->getWatcher($internalPath);
+ if (!$data or $data['size'] === -1) {
$this->lockFile($directory, ILockingProvider::LOCK_SHARED);
-
- $data = $cache->get($internalPath);
- $watcher = $storage->getWatcher($internalPath);
- if (!$data or $data['size'] === -1) {
- 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);
- } else if ($watcher->checkUpdate($internalPath, $data)) {
- $this->updater->propagate($path);
- $data = $cache->get($internalPath);
+ 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);
+ }
$folderId = $data['fileid'];
$contents = $cache->getFolderContentsById($folderId); //TODO: mimetype_filter
- $this->unlockFile($directory, ILockingProvider::LOCK_SHARED);
- } catch (LockedException $e) {
- // dont try to update the cache when the file is locked
- $contents = $cache->getFolderContents($internalPath);
- }
-
foreach ($contents as $content) {
if ($content['permissions'] === 0) {
$content['permissions'] = $storage->getPermissions($content['path']);