diff options
Diffstat (limited to 'lib/private/files/objectstore/homeobjectstorestorage.php')
-rw-r--r-- | lib/private/files/objectstore/homeobjectstorestorage.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/private/files/objectstore/homeobjectstorestorage.php b/lib/private/files/objectstore/homeobjectstorestorage.php index 0c889725828..26a2788d860 100644 --- a/lib/private/files/objectstore/homeobjectstorestorage.php +++ b/lib/private/files/objectstore/homeobjectstorestorage.php @@ -20,15 +20,52 @@ namespace OC\Files\ObjectStore; +use OC\User\User; + class HomeObjectStoreStorage extends ObjectStoreStorage { + /** + * The home user storage requires a user object to create a unique storage id + * @param array $params + */ public function __construct($params) { + if ( ! isset($params['user']) || ! $params['user'] instanceof User) { + throw new \Exception('missing user object in parameters'); + } + $this->user = $params['user']; parent::__construct($params); + //initialize cache with root directory in cache if ( ! $this->is_dir('files') ) { $this->mkdir('files'); } } + public function getId () { + 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 + */ + public function getOwner($path) { + if (is_object($this->user)) { + return $this->user->getUID(); + } + return false; + } + + /** + * @param string $path, optional + * @return \OC\User\User + */ + public function getUser($path = null) { + return $this->user; + } + + }
\ No newline at end of file |