diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-06-16 16:02:30 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-03 11:11:58 +0200 |
commit | 3e97ca3b9637a44ffd366838164461bda65e889f (patch) | |
tree | 08a3dc169eea3e0eb516051c77d6aa31bd66748c /lib | |
parent | f70791653cefc40f640e48dcad489237b750d85c (diff) | |
download | nextcloud-server-3e97ca3b9637a44ffd366838164461bda65e889f.tar.gz nextcloud-server-3e97ca3b9637a44ffd366838164461bda65e889f.zip |
Add getUserFolder to IRootFolder
* untangle DI of user specific folders
* allows to autodetect the dependency
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/node/root.php | 29 | ||||
-rw-r--r-- | lib/private/server.php | 22 | ||||
-rw-r--r-- | lib/private/util.php | 6 | ||||
-rw-r--r-- | lib/public/files/irootfolder.php | 8 | ||||
-rw-r--r-- | lib/public/iservercontainer.php | 1 |
5 files changed, 42 insertions, 24 deletions
diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php index 7ffb3674a8f..4df926748de 100644 --- a/lib/private/files/node/root.php +++ b/lib/private/files/node/root.php @@ -323,4 +323,33 @@ class Root extends Folder implements IRootFolder { public function getName() { return ''; } + + /** + * Returns a view to user's files folder + * + * @param String $userId user ID + * @return \OCP\Files\Folder + */ + public function getUserFolder($userId) { + \OC\Files\Filesystem::initMountPoints($userId); + $dir = '/' . $userId; + $folder = null; + + if (!$this->nodeExists($dir)) { + $folder = $this->newFolder($dir); + } else { + $folder = $this->get($dir); + } + + $dir = '/files'; + if (!$folder->nodeExists($dir)) { + $folder = $folder->newFolder($dir); + \OC_Util::copySkeleton($userId, $folder); + } else { + $folder = $folder->get($dir); + } + + return $folder; + + } } diff --git a/lib/private/server.php b/lib/private/server.php index af137ce36aa..84141fe28c1 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -535,29 +535,9 @@ class Server extends SimpleContainer implements IServerContainer { return null; } $userId = $user->getUID(); - } else { - $user = $this->getUserManager()->get($userId); } - \OC\Files\Filesystem::initMountPoints($userId); - $dir = '/' . $userId; $root = $this->getRootFolder(); - $folder = null; - - if (!$root->nodeExists($dir)) { - $folder = $root->newFolder($dir); - } else { - $folder = $root->get($dir); - } - - $dir = '/files'; - if (!$folder->nodeExists($dir)) { - $folder = $folder->newFolder($dir); - \OC_Util::copySkeleton($user, $folder); - } else { - $folder = $folder->get($dir); - } - - return $folder; + return $root->getUserFolder($userId); } /** diff --git a/lib/private/util.php b/lib/private/util.php index 9c78ad3ad1c..ab2d4a221d7 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -267,17 +267,17 @@ class OC_Util { /** * copies the skeleton to the users /files * - * @param \OC\User\User $user + * @param String $userId * @param \OCP\Files\Folder $userDirectory */ - public static function copySkeleton(\OC\User\User $user, \OCP\Files\Folder $userDirectory) { + public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) { $skeletonDirectory = \OCP\Config::getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton'); if (!empty($skeletonDirectory)) { \OCP\Util::writeLog( 'files_skeleton', - 'copying skeleton for '.$user->getUID().' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'), + 'copying skeleton for '.$userId.' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'), \OCP\Util::DEBUG ); self::copyr($skeletonDirectory, $userDirectory); diff --git a/lib/public/files/irootfolder.php b/lib/public/files/irootfolder.php index 19192cd9cc9..97dc5a31e74 100644 --- a/lib/public/files/irootfolder.php +++ b/lib/public/files/irootfolder.php @@ -33,5 +33,13 @@ use OC\Hooks\Emitter; */ interface IRootFolder extends Folder, Emitter { + /** + * Returns a view to user's files folder + * + * @param String $userId user ID + * @return \OCP\Files\Folder + * @since 8.2.0 + */ + public function getUserFolder($userId); } diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index ef6c6044951..95ee853d84c 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -99,6 +99,7 @@ interface IServerContainer { * @param string $userId user ID * @return \OCP\Files\Folder * @since 6.0.0 - parameter $userId was added in 8.0.0 + * @see getUserFolder in \OCP\Files\IRootFolder */ public function getUserFolder($userId = null); |