Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize getUserFolder for the common case
Browse files Browse the repository at this point in the history
icewind1991 committed Aug 25, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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
@@ -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);
}

0 comments on commit 512fe1c

Please sign in to comment.