Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-04-01 15:24:21 +0300
committerGitHub <noreply@github.com>2020-04-01 15:24:21 +0300
commitc1368b86963b93a42ec98a856f8d307d922c8967 (patch)
tree5ee70765b9bcdfc98fee97717d5c002b62f0f8d2 /lib
parent32577f2f574ccce141143e773c6aaa0f7ad0f57b (diff)
parent93411a2ea093536cff648da9cb5a6ee03bc4c9de (diff)
Merge pull request #19781 from nextcloud/quota-include-external-dont-use-current-user
Dont always use the current users quota when calculating storage info
Diffstat (limited to 'lib')
-rw-r--r--lib/private/legacy/helper.php20
-rw-r--r--lib/private/legacy/util.php8
2 files changed, 11 insertions, 17 deletions
diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php
index 67d70e10bcf..626295af5a9 100644
--- a/lib/private/legacy/helper.php
+++ b/lib/private/legacy/helper.php
@@ -43,6 +43,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
+use OCP\IUser;
use Symfony\Component\Process\ExecutableFinder;
/**
@@ -504,19 +506,14 @@ class OC_Helper {
|| $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')
) {
/** @var \OC\Files\Storage\Home $storage */
- $userInstance = $storage->getUser();
- $user = ($userInstance === null) ? null : $userInstance->getUID();
- } else {
- $user = \OC::$server->getUserSession()->getUser()->getUID();
- }
- if ($user) {
- $quota = OC_Util::getUserQuota($user);
+ $user = $storage->getUser();
} else {
- $quota = \OCP\Files\FileInfo::SPACE_UNLIMITED;
+ $user = \OC::$server->getUserSession()->getUser();
}
+ $quota = OC_Util::getUserQuota($user);
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
// always get free space / total space from root + mount points
- return self::getGlobalStorageInfo();
+ return self::getGlobalStorageInfo($quota);
}
}
@@ -562,11 +559,10 @@ class OC_Helper {
/**
* Get storage info including all mount points and quota
*
+ * @param int $quota
* @return array
*/
- private static function getGlobalStorageInfo() {
- $quota = OC_Util::getUserQuota(\OCP\User::getUser());
-
+ private static function getGlobalStorageInfo($quota) {
$rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
$used = $rootInfo['size'];
if ($used < 0) {
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index 9fce2993a2a..f14095675dc 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -251,8 +251,7 @@ class OC_Util {
) {
/** @var \OC\Files\Storage\Home $storage */
if (is_object($storage->getUser())) {
- $user = $storage->getUser()->getUID();
- $quota = OC_Util::getUserQuota($user);
+ $quota = OC_Util::getUserQuota($storage->getUser());
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
return new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => $quota, 'root' => 'files']);
}
@@ -375,11 +374,10 @@ class OC_Util {
/**
* Get the quota of a user
*
- * @param string $userId
+ * @param IUser|null $user
* @return float Quota bytes
*/
- public static function getUserQuota($userId) {
- $user = \OC::$server->getUserManager()->get($userId);
+ public static function getUserQuota(?IUser $user) {
if (is_null($user)) {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}