only lock in getDirectoryContent if we need to update the cache

This commit is contained in:
Robin Appelman 2015-10-26 15:08:17 +01:00
parent 4f2656993e
commit fc7f7e5c37
1 changed files with 17 additions and 21 deletions

View File

@ -1276,12 +1276,10 @@ class View {
*/
$files = array();
try {
$this->lockFile($directory, ILockingProvider::LOCK_SHARED);
$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)) {
$this->unlockFile($directory, ILockingProvider::LOCK_SHARED);
return array();
@ -1289,20 +1287,18 @@ class View {
$scanner = $storage->getScanner($internalPath);
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
$data = $cache->get($internalPath);
} else if ($watcher->checkUpdate($internalPath, $data)) {
$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']);