]> source.dussan.org Git - nextcloud-server.git/commitdiff
optimize getUserFolder for the common case 1054/head
authorRobin Appelman <robin@icewind.nl>
Thu, 25 Aug 2016 13:50:02 +0000 (15:50 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 25 Aug 2016 15:22:25 +0000 (17:22 +0200)
lib/private/Files/Node/Root.php

index e5921206a3953dbfc5518a214d14dc3f6cd1fbd8..007847fb513b14a0b754e47c6c598e560abc388a 100644 (file)
@@ -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);
                }