From fb88d668575562407edcaf392ec6f771cba55dba Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 25 Aug 2016 15:50:02 +0200 Subject: [PATCH] optimize getUserFolder for the common case --- lib/private/Files/Node/Root.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index e5921206a39..007847fb513 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -341,22 +341,17 @@ class Root extends Folder implements IRootFolder { public function getUserFolder($userId) { if (!$this->userFolderCache->hasKey($userId)) { \OC\Files\Filesystem::initMountPoints($userId); - $dir = '/' . $userId; - $folder = null; try { - $folder = $this->get($dir); + $folder = $this->get('/' . $userId . '/files'); } catch (NotFoundException $e) { - $folder = $this->newFolder($dir); - } - - $dir = '/files'; - try { - $folder = $folder->get($dir); - } catch (NotFoundException $e) { - $folder = $folder->newFolder($dir); + if (!$this->nodeExists('/' . $userId)) { + $this->newFolder('/' . $userId); + } + $folder = $this->newFolder('/' . $userId . '/files'); \OC_Util::copySkeleton($userId, $folder); } + $this->userFolderCache->set($userId, $folder); } -- 2.39.5