From 366d75e9479b1ac2b52b6a37389a4aa107b059e3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 11 Dec 2013 16:22:26 +0100 Subject: cache the home folder of a User --- lib/private/user/user.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/private/user/user.php') diff --git a/lib/private/user/user.php b/lib/private/user/user.php index e773473ec41..a9e32b5d597 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -37,6 +37,11 @@ class User { */ private $emitter; + /** + * @var string $home + */ + private $home; + /** * @param string $uid * @param \OC_User_Backend $backend @@ -133,10 +138,13 @@ class User { * @return string */ public function getHome() { - if ($this->backend->implementsActions(\OC_USER_BACKEND_GET_HOME) and $home = $this->backend->getHome($this->uid)) { - return $home; + if (!$this->home) { + if ($this->backend->implementsActions(\OC_USER_BACKEND_GET_HOME) and $home = $this->backend->getHome($this->uid)) { + $this->home = $home; + } + $this->home = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $this->uid; //TODO switch to Config object once implemented } - return \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $this->uid; //TODO switch to Config object once implemented + return $this->home; } /** @@ -145,7 +153,7 @@ class User { * @return bool */ public function canChangeAvatar() { - if($this->backend->implementsActions(\OC_USER_BACKEND_PROVIDE_AVATAR)) { + if ($this->backend->implementsActions(\OC_USER_BACKEND_PROVIDE_AVATAR)) { return $this->backend->canChangeAvatar($this->uid); } return true; -- cgit v1.2.3