diff options
-rw-r--r-- | lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php | 36 | ||||
-rw-r--r-- | tests/lib/Files/Mount/ObjectHomeMountProviderTest.php | 2 |
2 files changed, 31 insertions, 7 deletions
diff --git a/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php b/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php index 19ea5c872e0..275f7e37880 100644 --- a/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php +++ b/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php @@ -33,9 +33,14 @@ class PrimaryObjectStoreConfig { * @return ?ObjectStoreConfig */ public function getObjectStoreConfigForRoot(): ?array { - $config = $this->getObjectStoreConfig(); + $configs = $this->getObjectStoreConfig(); + if (!$configs) { + return null; + } + + $config = $configs['root'] ?? $configs['default']; - if ($config && $config['arguments']['multibucket']) { + if ($config['arguments']['multibucket']) { if (!isset($config['arguments']['bucket'])) { $config['arguments']['bucket'] = ''; } @@ -50,9 +55,20 @@ class PrimaryObjectStoreConfig { * @return ?ObjectStoreConfig */ public function getObjectStoreConfigForUser(IUser $user): ?array { - $config = $this->getObjectStoreConfig(); + $configs = $this->getObjectStoreConfig(); + if (!$configs) { + return null; + } + + $store = $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'objectstore', null); - if ($config && $config['arguments']['multibucket']) { + if ($store) { + $config = $configs[$store]; + } else { + $config = $configs['default']; + } + + if ($config['arguments']['multibucket']) { $config['arguments']['bucket'] = $this->getBucketForUser($user, $config); } return $config; @@ -68,9 +84,17 @@ class PrimaryObjectStoreConfig { // new-style multibucket config uses the same 'objectstore' key but sets `'multibucket' => true`, transparently upgrade older style config if ($objectStoreMultiBucket) { $objectStoreMultiBucket['arguments']['multibucket'] = true; - return $this->validateObjectStoreConfig($objectStoreMultiBucket); + return [ + 'default' => $this->validateObjectStoreConfig($objectStoreMultiBucket) + ]; } elseif($objectStore) { - return $this->validateObjectStoreConfig($objectStore); + if (!isset($objectStore['default'])) { + $objectStore = [ + 'default' => $objectStore, + ]; + } + + return array_map($this->validateObjectStoreConfig(...), $objectStore); } else { return null; } diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php index 2a68e4ed8fb..deb3fb07189 100644 --- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php +++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php @@ -83,7 +83,7 @@ class ObjectHomeMountProviderTest extends \Test\TestCase { $this->config->method('getUserValue') ->willReturn(null); - $this->config->expects($this->once()) + $this->config ->method('setUserValue') ->with( $this->equalTo('uid'), |