2022-02-10 09:37:57 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2022-02-10 09:37:57 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace OC\Files\Mount;
|
|
|
|
|
|
|
|
|
|
use OC;
|
|
|
|
|
use OC\Files\ObjectStore\ObjectStoreStorage;
|
2022-11-30 09:48:45 -05:00
|
|
|
use OC\Files\ObjectStore\PrimaryObjectStoreConfig;
|
2022-02-10 09:37:57 -05:00
|
|
|
use OC\Files\Storage\LocalRootStorage;
|
|
|
|
|
use OCP\Files\Config\IRootMountProvider;
|
|
|
|
|
use OCP\Files\Storage\IStorageFactory;
|
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
|
|
|
|
|
class RootMountProvider implements IRootMountProvider {
|
2025-11-17 09:32:54 -05:00
|
|
|
public function __construct(
|
|
|
|
|
private PrimaryObjectStoreConfig $objectStoreConfig,
|
|
|
|
|
private IConfig $config,
|
|
|
|
|
) {
|
2022-02-10 09:37:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getRootMounts(IStorageFactory $loader): array {
|
2022-11-30 09:48:45 -05:00
|
|
|
$objectStoreConfig = $this->objectStoreConfig->getObjectStoreConfigForRoot();
|
2022-02-10 09:37:57 -05:00
|
|
|
|
2022-11-30 09:48:45 -05:00
|
|
|
if ($objectStoreConfig) {
|
|
|
|
|
return [$this->getObjectStoreRootMount($loader, $objectStoreConfig)];
|
2022-02-10 09:37:57 -05:00
|
|
|
} else {
|
|
|
|
|
return [$this->getLocalRootMount($loader)];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getLocalRootMount(IStorageFactory $loader): MountPoint {
|
|
|
|
|
$configDataDirectory = $this->config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data');
|
|
|
|
|
return new MountPoint(LocalRootStorage::class, '/', ['datadir' => $configDataDirectory], $loader, null, null, self::class);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 09:48:45 -05:00
|
|
|
private function getObjectStoreRootMount(IStorageFactory $loader, array $objectStoreConfig): MountPoint {
|
|
|
|
|
$arguments = array_merge($objectStoreConfig['arguments'], [
|
|
|
|
|
'objectstore' => $this->objectStoreConfig->buildObjectStore($objectStoreConfig),
|
|
|
|
|
]);
|
2022-02-10 09:37:57 -05:00
|
|
|
|
2022-11-30 09:48:45 -05:00
|
|
|
return new MountPoint(ObjectStoreStorage::class, '/', $arguments, $loader, null, null, self::class);
|
2022-02-10 09:37:57 -05:00
|
|
|
}
|
|
|
|
|
}
|