Merge pull request #19781 from nextcloud/quota-include-external-dont-use-current-user
Dont always use the current users quota when calculating storage info
This commit is contained in:
commit
c1368b8696
|
@ -43,6 +43,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use OCP\IUser;
|
||||||
use Symfony\Component\Process\ExecutableFinder;
|
use Symfony\Component\Process\ExecutableFinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -504,19 +506,14 @@ class OC_Helper {
|
||||||
|| $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')
|
|| $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')
|
||||||
) {
|
) {
|
||||||
/** @var \OC\Files\Storage\Home $storage */
|
/** @var \OC\Files\Storage\Home $storage */
|
||||||
$userInstance = $storage->getUser();
|
$user = $storage->getUser();
|
||||||
$user = ($userInstance === null) ? null : $userInstance->getUID();
|
|
||||||
} else {
|
} else {
|
||||||
$user = \OC::$server->getUserSession()->getUser()->getUID();
|
$user = \OC::$server->getUserSession()->getUser();
|
||||||
}
|
|
||||||
if ($user) {
|
|
||||||
$quota = OC_Util::getUserQuota($user);
|
|
||||||
} else {
|
|
||||||
$quota = \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
|
||||||
}
|
}
|
||||||
|
$quota = OC_Util::getUserQuota($user);
|
||||||
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
|
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
|
||||||
// always get free space / total space from root + mount points
|
// 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
|
* Get storage info including all mount points and quota
|
||||||
*
|
*
|
||||||
|
* @param int $quota
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function getGlobalStorageInfo() {
|
private static function getGlobalStorageInfo($quota) {
|
||||||
$quota = OC_Util::getUserQuota(\OCP\User::getUser());
|
|
||||||
|
|
||||||
$rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
|
$rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
|
||||||
$used = $rootInfo['size'];
|
$used = $rootInfo['size'];
|
||||||
if ($used < 0) {
|
if ($used < 0) {
|
||||||
|
|
|
@ -251,8 +251,7 @@ class OC_Util {
|
||||||
) {
|
) {
|
||||||
/** @var \OC\Files\Storage\Home $storage */
|
/** @var \OC\Files\Storage\Home $storage */
|
||||||
if (is_object($storage->getUser())) {
|
if (is_object($storage->getUser())) {
|
||||||
$user = $storage->getUser()->getUID();
|
$quota = OC_Util::getUserQuota($storage->getUser());
|
||||||
$quota = OC_Util::getUserQuota($user);
|
|
||||||
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
|
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
|
||||||
return new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => $quota, 'root' => 'files']);
|
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
|
* Get the quota of a user
|
||||||
*
|
*
|
||||||
* @param string $userId
|
* @param IUser|null $user
|
||||||
* @return float Quota bytes
|
* @return float Quota bytes
|
||||||
*/
|
*/
|
||||||
public static function getUserQuota($userId) {
|
public static function getUserQuota(?IUser $user) {
|
||||||
$user = \OC::$server->getUserManager()->get($userId);
|
|
||||||
if (is_null($user)) {
|
if (is_null($user)) {
|
||||||
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue