Skip to content

Commit

Permalink
optimize getUserFolder for the common case
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Aug 25, 2016
1 parent 71d672a commit 512fe1c
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/private/Files/Node/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 512fe1c

Please sign in to comment.