mirror of
https://github.com/nextcloud/server.git
synced 2026-05-22 10:06:37 -04:00
fix(OC_Helper): properly calculate quota of shared storages
- resolves https://github.com/nextcloud/server/issues/55659 First we need to properly handle shared storages, because there the quota is the quota of the user who owns the nodes, not the user who shared the nodes. Second if no user can be fetched then we cannot get the global storage info, thus in this case (public share?) we need to safe-guard. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
63680bdce5
commit
29fc48e083
2 changed files with 13 additions and 7 deletions
|
|
@ -4241,9 +4241,6 @@
|
|||
<InternalMethod>
|
||||
<code><![CDATA[getAbsolutePath]]></code>
|
||||
</InternalMethod>
|
||||
<UndefinedInterfaceMethod>
|
||||
<code><![CDATA[getQuota]]></code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="lib/private/legacy/OC_User.php">
|
||||
<UndefinedClass>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
use bantu\IniGetWrapper\IniGetWrapper;
|
||||
use OC\Files\FilenameValidator;
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\ObjectStore\HomeObjectStoreStorage;
|
||||
use OC\Files\Storage\Home;
|
||||
use OC\Files\Storage\Wrapper\Quota;
|
||||
use OC\SystemConfig;
|
||||
|
|
@ -15,6 +16,7 @@ use OCA\Files_Sharing\External\Storage;
|
|||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\Mount\IMountPoint;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\Storage\ISharedStorage;
|
||||
use OCP\IBinaryFinder;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -190,16 +192,23 @@ class OC_Helper {
|
|||
self::$quotaIncludeExternalStorage = false;
|
||||
}
|
||||
if (self::$quotaIncludeExternalStorage) {
|
||||
if ($storage->instanceOfStorage('\OC\Files\Storage\Home')
|
||||
if ($storage->instanceOfStorage(ISharedStorage::class)) {
|
||||
// we must use the shared nodes owner,
|
||||
// because if user A shared a file with user B and B shares this again,
|
||||
// then the share initiator is user B but the quota that this counts in is user A's quota.
|
||||
/** @var ISharedStorage $storage */
|
||||
$user = $storage->getShare()->getNode()->getOwner();
|
||||
} elseif (
|
||||
$storage->instanceOfStorage('\OC\Files\Storage\Home')
|
||||
|| $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')
|
||||
) {
|
||||
/** @var Home $storage */
|
||||
/** @var Home|HomeObjectStoreStorage $storage */
|
||||
$user = $storage->getUser();
|
||||
} else {
|
||||
$user = Server::get(IUserSession::class)->getUser();
|
||||
}
|
||||
$quota = $user?->getQuotaBytes() ?? FileInfo::SPACE_UNKNOWN;
|
||||
if ($quota !== FileInfo::SPACE_UNLIMITED) {
|
||||
if ($user !== null && $quota !== FileInfo::SPACE_UNLIMITED) {
|
||||
// always get free space / total space from root + mount points
|
||||
return self::getGlobalStorageInfo($quota, $user, $mount);
|
||||
}
|
||||
|
|
@ -207,7 +216,7 @@ class OC_Helper {
|
|||
|
||||
// TODO: need a better way to get total space from storage
|
||||
if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')) {
|
||||
/** @var Quota $storage */
|
||||
/** @var Quota $sourceStorage */
|
||||
$quota = $sourceStorage->getQuota();
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue