summaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/Manager.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-05-03 11:58:33 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-06-14 10:17:06 +0200
commitae3d0d96fe7e273f6dfae3a5ca4754b5da4353cc (patch)
treecada27196a9e228861713ed19e76d14416e28f8c /lib/private/Share20/Manager.php
parentd0a2515e2b08bffac3e3f447cc78c24f372a0589 (diff)
downloadnextcloud-server-ae3d0d96fe7e273f6dfae3a5ca4754b5da4353cc.tar.gz
nextcloud-server-ae3d0d96fe7e273f6dfae3a5ca4754b5da4353cc.zip
Optimize isSharingDisabledForuser
Diffstat (limited to 'lib/private/Share20/Manager.php')
-rw-r--r--lib/private/Share20/Manager.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index ceaaa58cf6e..2b1c7d828f1 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -24,25 +24,24 @@
namespace OC\Share20;
+use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\MoveableMount;
+use OCP\Files\File;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\Mount\IMountManager;
use OCP\Files\NotFoundException;
-use OCP\IUserManager;
-use OCP\Share\IManager;
-use OCP\Share\IProviderFactory;
-use OC\Share20\Exception\BackendError;
use OCP\IConfig;
+use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
-use OCP\Security\ISecureRandom;
+use OCP\IUserManager;
use OCP\Security\IHasher;
-use OCP\Files\Mount\IMountManager;
-use OCP\IGroupManager;
-use OCP\Files\File;
-use OCP\Files\Folder;
-
-use OCP\Share\Exceptions\ShareNotFound;
+use OCP\Security\ISecureRandom;
use OCP\Share\Exceptions\GenericShareException;
+use OCP\Share\Exceptions\ShareNotFound;
+use OCP\Share\IManager;
+use OCP\Share\IProviderFactory;
/**
* This class is the communication hub for all sharing related operations.
@@ -69,6 +68,9 @@ class Manager implements IManager {
private $userManager;
/** @var IRootFolder */
private $rootFolder;
+ /** @var CappedMemoryCache */
+ private $sharingDisabledForUsersCache;
+
/**
* Manager constructor.
@@ -106,6 +108,7 @@ class Manager implements IManager {
$this->factory = $factory;
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
+ $this->sharingDisabledForUsersCache = new CappedMemoryCache();
}
/**
@@ -1209,6 +1212,10 @@ class Manager implements IManager {
* @return bool
*/
public function sharingDisabledForUser($userId) {
+ if (isset($this->sharingDisabledForUsersCache[$userId])) {
+ return $this->sharingDisabledForUsersCache[$userId];
+ }
+
if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
$groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroups = json_decode($groupsList);
@@ -1224,10 +1231,13 @@ class Manager implements IManager {
// if the user is only in groups which are disabled for sharing then
// sharing is also disabled for the user
if (empty($remainingGroups)) {
+ $this->sharingDisabledForUsersCache[$userId] = true;
return true;
}
}
}
+
+ $this->sharingDisabledForUsersCache[$userId] = false;
return false;
}