mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #40981 from nextcloud/fix/object-storage-user
fix(objectstorage): cleanup HomeObjectStoreStorage
This commit is contained in:
commit
8a4bd3b932
4 changed files with 33 additions and 39 deletions
|
|
@ -26,9 +26,12 @@ declare(strict_types=1);
|
|||
namespace OC\Files\ObjectStore;
|
||||
|
||||
class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage {
|
||||
/** @var string */
|
||||
private $internalId;
|
||||
private string $internalId;
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($params) {
|
||||
if (!isset($params['internal-id'])) {
|
||||
throw new \Exception('missing id in parameters');
|
||||
|
|
@ -37,7 +40,7 @@ class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage {
|
|||
parent::__construct($params);
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
public function getId(): string {
|
||||
return 'object::appdata::preview:' . $this->internalId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
|
||||
* @author Morris Jobke <hey@morrisjobke.de>
|
||||
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
||||
* @author Thomas Citharel <nextcloud@tcit.fr>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
|
|
@ -25,23 +26,28 @@
|
|||
*/
|
||||
namespace OC\Files\ObjectStore;
|
||||
|
||||
use OC\User\User;
|
||||
use Exception;
|
||||
use OCP\Files\IHomeStorage;
|
||||
use OCP\IUser;
|
||||
|
||||
class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IHomeStorage {
|
||||
class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage {
|
||||
protected IUser $user;
|
||||
|
||||
/**
|
||||
* The home user storage requires a user object to create a unique storage id
|
||||
*
|
||||
* @param array $params
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($params) {
|
||||
if (! isset($params['user']) || ! $params['user'] instanceof User) {
|
||||
throw new \Exception('missing user object in parameters');
|
||||
if (! isset($params['user']) || ! $params['user'] instanceof IUser) {
|
||||
throw new Exception('missing user object in parameters');
|
||||
}
|
||||
$this->user = $params['user'];
|
||||
parent::__construct($params);
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
public function getId(): string {
|
||||
return 'object::user:' . $this->user->getUID();
|
||||
}
|
||||
|
||||
|
|
@ -49,20 +55,13 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IH
|
|||
* get the owner of a path
|
||||
*
|
||||
* @param string $path The path to get the owner
|
||||
* @return false|string uid
|
||||
* @return string uid
|
||||
*/
|
||||
public function getOwner($path) {
|
||||
if (is_object($this->user)) {
|
||||
return $this->user->getUID();
|
||||
}
|
||||
return false;
|
||||
public function getOwner($path): string {
|
||||
return $this->user->getUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path, optional
|
||||
* @return \OC\User\User
|
||||
*/
|
||||
public function getUser($path = null): IUser {
|
||||
public function getUser(): IUser {
|
||||
return $this->user;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,32 +47,24 @@ use OCP\Files\ObjectStore\IObjectStore;
|
|||
use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload;
|
||||
use OCP\Files\Storage\IChunkedFileWrite;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use OCP\ILogger;
|
||||
|
||||
class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFileWrite {
|
||||
use CopyDirectory;
|
||||
|
||||
/**
|
||||
* @var \OCP\Files\ObjectStore\IObjectStore $objectStore
|
||||
*/
|
||||
protected $objectStore;
|
||||
/**
|
||||
* @var string $id
|
||||
*/
|
||||
protected $id;
|
||||
/**
|
||||
* @var \OC\User\User $user
|
||||
*/
|
||||
protected $user;
|
||||
protected IObjectStore $objectStore;
|
||||
protected string $id;
|
||||
private string $objectPrefix = 'urn:oid:';
|
||||
|
||||
private $objectPrefix = 'urn:oid:';
|
||||
|
||||
private $logger;
|
||||
private ILogger $logger;
|
||||
|
||||
private bool $handleCopiesAsOwned;
|
||||
protected bool $validateWrites = true;
|
||||
|
||||
/** @var bool */
|
||||
protected $validateWrites = true;
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($params) {
|
||||
if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
|
||||
$this->objectStore = $params['objectstore'];
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use OCP\Files\ObjectStore\IObjectStore;
|
|||
* Allow overwriting the object store instance for test purposes
|
||||
*/
|
||||
class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
|
||||
public function setObjectStore(IObjectStore $objectStore) {
|
||||
public function setObjectStore(IObjectStore $objectStore): void {
|
||||
$this->objectStore = $objectStore;
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
|
|||
return $this->objectStore;
|
||||
}
|
||||
|
||||
public function setValidateWrites(bool $validate) {
|
||||
public function setValidateWrites(bool $validate): void {
|
||||
$this->validateWrites = $validate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue