2016-05-17 15:40:55 -04:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2016-05-17 15:40:55 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-05-17 15:40:55 -04:00
|
|
|
*/
|
|
|
|
|
namespace OC\Files\Mount;
|
|
|
|
|
|
2022-11-30 09:48:45 -05:00
|
|
|
use OC\Files\ObjectStore\HomeObjectStoreStorage;
|
|
|
|
|
use OC\Files\ObjectStore\PrimaryObjectStoreConfig;
|
2016-05-17 15:40:55 -04:00
|
|
|
use OCP\Files\Config\IHomeMountProvider;
|
2022-11-30 09:48:45 -05:00
|
|
|
use OCP\Files\Mount\IMountPoint;
|
2016-05-17 15:40:55 -04:00
|
|
|
use OCP\Files\Storage\IStorageFactory;
|
|
|
|
|
use OCP\IUser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mount provider for object store home storages
|
|
|
|
|
*/
|
|
|
|
|
class ObjectHomeMountProvider implements IHomeMountProvider {
|
2022-11-30 09:48:45 -05:00
|
|
|
public function __construct(
|
|
|
|
|
private PrimaryObjectStoreConfig $objectStoreConfig,
|
|
|
|
|
) {
|
2016-05-17 15:40:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-11-30 09:48:45 -05:00
|
|
|
* Get the home mount for a user
|
2016-05-17 15:40:55 -04:00
|
|
|
*
|
|
|
|
|
* @param IUser $user
|
|
|
|
|
* @param IStorageFactory $loader
|
2022-11-30 09:48:45 -05:00
|
|
|
* @return ?IMountPoint
|
2016-05-17 15:40:55 -04:00
|
|
|
*/
|
2022-11-30 09:48:45 -05:00
|
|
|
public function getHomeMountForUser(IUser $user, IStorageFactory $loader): ?IMountPoint {
|
|
|
|
|
$objectStoreConfig = $this->objectStoreConfig->getObjectStoreConfigForUser($user);
|
|
|
|
|
if ($objectStoreConfig === null) {
|
2016-05-22 14:44:06 -04:00
|
|
|
return null;
|
|
|
|
|
}
|
2022-11-30 09:48:45 -05:00
|
|
|
$arguments = array_merge($objectStoreConfig['arguments'], [
|
|
|
|
|
'objectstore' => $this->objectStoreConfig->buildObjectStore($objectStoreConfig),
|
|
|
|
|
'user' => $user,
|
|
|
|
|
]);
|
2016-05-22 14:44:06 -04:00
|
|
|
|
2022-11-30 09:48:45 -05:00
|
|
|
return new HomeMountPoint($user, HomeObjectStoreStorage::class, '/' . $user->getUID(), $arguments, $loader, null, null, self::class);
|
2016-05-17 15:40:55 -04:00
|
|
|
}
|
|
|
|
|
}
|