summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-09-02 15:41:59 +0200
committerRobin Appelman <robin@icewind.nl>2016-09-07 17:22:40 +0200
commite8e950a4d2972a4950e00a67cc8c1f0447701986 (patch)
tree17af82302f0000d88391fa4df5ecde419e991645 /apps/files_external
parent1d04c9e307892c275f9fad64ef0ebe9bc10e0260 (diff)
downloadnextcloud-server-e8e950a4d2972a4950e00a67cc8c1f0447701986.tar.gz
nextcloud-server-e8e950a4d2972a4950e00a67cc8c1f0447701986.zip
more efficient querying of numeric storage ids
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Config/ConfigAdapter.php55
1 files changed, 32 insertions, 23 deletions
diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php
index 5d8e30b6da6..efeb3d75586 100644
--- a/apps/files_external/lib/Config/ConfigAdapter.php
+++ b/apps/files_external/lib/Config/ConfigAdapter.php
@@ -121,54 +121,63 @@ class ConfigAdapter implements IMountProvider {
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$this->migrator->migrateUser($user);
- $mounts = [];
-
$this->userStoragesService->setUser($user);
$this->userGlobalStoragesService->setUser($user);
- foreach ($this->userGlobalStoragesService->getAllStoragesForUser() as $storage) {
+ $storageConfigs = $this->userGlobalStoragesService->getAllStoragesForUser();
+
+ $storages = array_map(function(StorageConfig $storageConfig) use ($user) {
try {
- $this->prepareStorageConfig($storage, $user);
- $impl = $this->constructStorage($storage);
+ $this->prepareStorageConfig($storageConfig, $user);
+ return $this->constructStorage($storageConfig);
} catch (\Exception $e) {
// propagate exception into filesystem
- $impl = new FailedStorage(['exception' => $e]);
+ return new FailedStorage(['exception' => $e]);
}
+ }, $storageConfigs);
+
+ \OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function(Storage\IStorage $storage) {
+ return $storage->getId();
+ }, $storages));
+
+ $availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) {
try {
- $availability = $impl->getAvailability();
+ $availability = $storage->getAvailability();
if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
- $impl = new FailedStorage([
- 'exception' => new StorageNotAvailableException('Storage with mount id ' . $storage->getId() . ' is not available')
+ $storage = new FailedStorage([
+ 'exception' => new StorageNotAvailableException('Storage with mount id ' . $storageConfig->getId() . ' is not available')
]);
}
} catch (\Exception $e) {
// propagate exception into filesystem
- $impl = new FailedStorage(['exception' => $e]);
+ $storage = new FailedStorage(['exception' => $e]);
}
+ return $storage;
+ }, $storages, $storageConfigs);
- if ($storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
- $mount = new PersonalMount(
+ $mounts = array_map(function(StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
+ if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
+ return new PersonalMount(
$this->userStoragesService,
- $storage->getId(),
- $impl,
- '/' . $user->getUID() . '/files' . $storage->getMountPoint(),
+ $storageConfig->getId(),
+ $storage,
+ '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
null,
$loader,
- $storage->getMountOptions()
+ $storageConfig->getMountOptions()
);
} else {
- $mount = new MountPoint(
- $impl,
- '/' . $user->getUID() . '/files' . $storage->getMountPoint(),
+ return new MountPoint(
+ $storage,
+ '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
null,
$loader,
- $storage->getMountOptions(),
- $storage->getId()
+ $storageConfig->getMountOptions(),
+ $storageConfig->getId()
);
}
- $mounts[$storage->getMountPoint()] = $mount;
- }
+ }, $storageConfigs, $availableStorages);
$this->userStoragesService->resetUser();
$this->userGlobalStoragesService->resetUser();