aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Node/Root.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Files/Node/Root.php')
-rw-r--r--lib/private/Files/Node/Root.php42
1 files changed, 26 insertions, 16 deletions
diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php
index bad865a7987..e5921206a39 100644
--- a/lib/private/Files/Node/Root.php
+++ b/lib/private/Files/Node/Root.php
@@ -28,6 +28,7 @@
namespace OC\Files\Node;
+use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\Manager;
use OC\Files\Mount\MountPoint;
use OCP\Files\NotFoundException;
@@ -71,6 +72,8 @@ class Root extends Folder implements IRootFolder {
*/
private $user;
+ private $userFolderCache;
+
/**
* @param \OC\Files\Mount\Manager $manager
* @param \OC\Files\View $view
@@ -81,6 +84,7 @@ class Root extends Folder implements IRootFolder {
$this->mountManager = $manager;
$this->user = $user;
$this->emitter = new PublicEmitter();
+ $this->userFolderCache = new CappedMemoryCache();
}
/**
@@ -335,25 +339,31 @@ class Root extends Folder implements IRootFolder {
* @return \OCP\Files\Folder
*/
public function getUserFolder($userId) {
- \OC\Files\Filesystem::initMountPoints($userId);
- $dir = '/' . $userId;
- $folder = null;
-
- try {
- $folder = $this->get($dir);
- } catch (NotFoundException $e) {
- $folder = $this->newFolder($dir);
- }
+ if (!$this->userFolderCache->hasKey($userId)) {
+ \OC\Files\Filesystem::initMountPoints($userId);
+ $dir = '/' . $userId;
+ $folder = null;
+
+ try {
+ $folder = $this->get($dir);
+ } catch (NotFoundException $e) {
+ $folder = $this->newFolder($dir);
+ }
- $dir = '/files';
- try {
- $folder = $folder->get($dir);
- } catch (NotFoundException $e) {
- $folder = $folder->newFolder($dir);
- \OC_Util::copySkeleton($userId, $folder);
+ $dir = '/files';
+ try {
+ $folder = $folder->get($dir);
+ } catch (NotFoundException $e) {
+ $folder = $folder->newFolder($dir);
+ \OC_Util::copySkeleton($userId, $folder);
+ }
+ $this->userFolderCache->set($userId, $folder);
}
- return $folder;
+ return $this->userFolderCache->get($userId);
+ }
+ public function clearCache() {
+ $this->userFolderCache = new CappedMemoryCache();
}
}