2014-06-17 16:06:56 -04:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2014-06-17 16:06:56 -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
|
2014-06-17 16:06:56 -04:00
|
|
|
*/
|
|
|
|
|
namespace OC\Files\ObjectStore;
|
|
|
|
|
|
2023-10-20 03:08:08 -04:00
|
|
|
use Exception;
|
2023-10-19 09:31:44 -04:00
|
|
|
use OCP\Files\IHomeStorage;
|
2023-08-14 09:50:05 -04:00
|
|
|
use OCP\IUser;
|
2014-06-18 09:20:26 -04:00
|
|
|
|
2023-10-19 09:31:44 -04:00
|
|
|
class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage {
|
2023-10-20 03:09:50 -04:00
|
|
|
protected IUser $user;
|
|
|
|
|
|
2014-06-18 09:20:26 -04:00
|
|
|
/**
|
|
|
|
|
* The home user storage requires a user object to create a unique storage id
|
2023-10-20 03:08:08 -04:00
|
|
|
*
|
2024-10-08 09:13:16 -04:00
|
|
|
* @param array $parameters
|
2023-10-20 03:08:08 -04:00
|
|
|
* @throws Exception
|
2014-06-18 09:20:26 -04:00
|
|
|
*/
|
2024-10-08 09:13:16 -04:00
|
|
|
public function __construct(array $parameters) {
|
|
|
|
|
if (! isset($parameters['user']) || ! $parameters['user'] instanceof IUser) {
|
2023-10-20 03:08:08 -04:00
|
|
|
throw new Exception('missing user object in parameters');
|
2014-06-18 09:20:26 -04:00
|
|
|
}
|
2024-10-08 09:13:16 -04:00
|
|
|
$this->user = $parameters['user'];
|
|
|
|
|
parent::__construct($parameters);
|
2014-06-17 16:06:56 -04:00
|
|
|
}
|
|
|
|
|
|
2023-10-20 03:08:08 -04:00
|
|
|
public function getId(): string {
|
2014-06-18 09:20:26 -04:00
|
|
|
return 'object::user:' . $this->user->getUID();
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-01 10:12:30 -04:00
|
|
|
public function getOwner(string $path): string|false {
|
2023-10-20 03:08:08 -04:00
|
|
|
return $this->user->getUID();
|
2014-06-18 09:20:26 -04:00
|
|
|
}
|
|
|
|
|
|
2023-10-19 09:31:44 -04:00
|
|
|
public function getUser(): IUser {
|
2014-06-18 09:20:26 -04:00
|
|
|
return $this->user;
|
|
|
|
|
}
|
2019-11-22 14:52:10 -05:00
|
|
|
}
|