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

View file

@ -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']);