-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40981 from nextcloud/fix/object-storage-user
fix(objectstorage): cleanup HomeObjectStoreStorage
- Loading branch information
Showing
4 changed files
with
33 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* @author Jörn Friedrich Dreyer <[email protected]> | ||
* @author Morris Jobke <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Thomas Citharel <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
|
@@ -25,44 +26,42 @@ | |
*/ | ||
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(); | ||
} | ||
|
||
/** | ||
* 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters