summaryrefslogtreecommitdiffstats
path: root/lib/private/Share20
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-06-21 11:18:22 +0200
committerLukas Reschke <lukas@owncloud.com>2016-06-21 11:18:22 +0200
commit2b493e2f9dca674ba11f88a1d182d6872e04eaaa (patch)
treeef7fa75d1b4da812de80e93c3590dbb5404d7f06 /lib/private/Share20
parentb4df57f3f02f65ed71d1072280751170379a53e8 (diff)
parent0e575c7eeadc6c8eb11b0be2ed1d39cdcf6cfcb8 (diff)
downloadnextcloud-server-2b493e2f9dca674ba11f88a1d182d6872e04eaaa.tar.gz
nextcloud-server-2b493e2f9dca674ba11f88a1d182d6872e04eaaa.zip
Merge remote-tracking branch 'upstream/master' into master-sync-upstream
Diffstat (limited to 'lib/private/Share20')
-rw-r--r--lib/private/Share20/Manager.php36
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 5921bbc44c8..2857a394e1e 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();
}
/**
@@ -1212,6 +1215,14 @@ class Manager implements IManager {
* @return bool
*/
public function sharingDisabledForUser($userId) {
+ if ($userId === null) {
+ return false;
+ }
+
+ 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);
@@ -1227,10 +1238,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;
}