From 512fe1c57bf3a82de495a50002a1ef16994b6d76 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 e5921206a3953..007847fb513b1 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -341,22 +341,17 @@ public function getName() { 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); }