Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: allow configuring multiple objectstore configurations
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Nov 20, 2025
commit ff74df3528d7376adddc2a4ab85ee11b920b8857
38 changes: 31 additions & 7 deletions lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ public function buildObjectStore(array $config): IObjectStore {
* @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'] = '';
}
Expand All @@ -51,16 +56,27 @@ public function getObjectStoreConfigForRoot(): ?array {
* @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;
}

/**
* @return ?ObjectStoreConfig
* @return ?array<string, ObjectStoreConfig>
*/
private function getObjectStoreConfig(): ?array {
$objectStore = $this->config->getSystemValue('objectstore', null);
Expand All @@ -69,9 +85,17 @@ private function getObjectStoreConfig(): ?array {
// 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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testMultiBucket(): void {
$this->config->method('getUserValue')
->willReturn(null);

$this->config->expects($this->once())
$this->config
->method('setUserValue')
->with(
$this->equalTo('uid'),
Expand Down