diff options
author | Thomas Citharel <tcit@tcit.fr> | 2022-09-01 18:28:18 +0300 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2022-09-01 18:28:18 +0300 |
commit | 82198139269c937cf9f67360fd2dc61efd068de2 (patch) | |
tree | c3e81d738d49cdeac51814eae8e3adca16c3c119 | |
parent | 253c0641b138d6eeb4397f82ba3738d9adb132a2 (diff) |
Introduce a config parameter to have an instance-level quotainstance-quota
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
-rw-r--r-- | lib/private/Files/Storage/Common.php | 11 | ||||
-rw-r--r-- | lib/private/legacy/OC_Helper.php | 10 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index a7bc44e10e2..f3e59d96859 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -61,6 +61,7 @@ use OCP\Files\ReservedWordException; use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IWriteStreamStorage; +use OCP\IConfig; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; use Psr\Log\LoggerInterface; @@ -474,12 +475,20 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { } /** - * get the free space in the storage + * Get the free space in the storage + * + * In case the admin has overwritten the global instance quota, default to the quota instead of unknown * * @param string $path * @return int|false */ public function free_space($path) { + /** @var IConfig $config */ + $config = \OC::$server->get(IConfig::class); + $configQuota = (int) $config->getAppValue('core', 'quota_instance_global', '0'); + if ($configQuota > 0) { + return $configQuota; + } return \OCP\Files\FileInfo::SPACE_UNKNOWN; } diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index 710225c7474..518a162af45 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -48,6 +48,7 @@ use OC\Files\Filesystem; use OCP\Files\Mount\IMountPoint; use OCP\ICacheFactory; use OCP\IBinaryFinder; +use OCP\IConfig; use OCP\IUser; use Psr\Log\LoggerInterface; @@ -486,6 +487,15 @@ class OC_Helper { $used = 0; } $quota = \OCP\Files\FileInfo::SPACE_UNLIMITED; + + // If the admin overrides the global instance quota we default to the value set + /** @var IConfig $config */ + $config = \OC::$server->get(IConfig::class); + $configQuota = (int) $config->getAppValue('core', 'quota_instance_global', '0'); + if ($configQuota > 0) { + $quota = $configQuota; + } + $mount = $rootInfo->getMountPoint(); $storage = $mount->getStorage(); $sourceStorage = $storage; |