aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-03-04 17:20:27 +0100
committerRobin Appelman <robin@icewind.nl>2020-03-04 17:20:27 +0100
commit93411a2ea093536cff648da9cb5a6ee03bc4c9de (patch)
treeed9c34b647966ab90fd21c94365b35056aa32711 /lib/private/legacy
parent64a29d01a492db19289833ba9f485b7dca881cef (diff)
downloadnextcloud-server-93411a2ea093536cff648da9cb5a6ee03bc4c9de.tar.gz
nextcloud-server-93411a2ea093536cff648da9cb5a6ee03bc4c9de.zip
Dont always use the current users quota when calculating storage info
instead pass the quota as parameter. Without this fix, when 'quota_include_external_storage' is enabled, the webui will show the quota configured for the admin for every user instead of the users quota Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/legacy')
-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 3ddb9d07b14..19c9ca7f91c 100644
--- a/lib/private/legacy/helper.php
+++ b/lib/private/legacy/helper.php
@@ -42,6 +42,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
+use OCP\IUser;
use Symfony\Component\Process\ExecutableFinder;
/**
@@ -503,19 +505,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);
}
}
@@ -561,11 +558,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 bf0a1b9bb20..9b574993f2c 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(array('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;
}