Skip to content

Commit

Permalink
Introduce a config parameter to have an instance-level quota
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
  • Loading branch information
tcitworld committed Sep 1, 2022
1 parent 253c064 commit 8219813
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
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;
Expand Down Expand Up @@ -474,12 +475,20 @@ public function test() {
}

/**
* 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;
}

Expand Down
10 changes: 10 additions & 0 deletions lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use OCP\Files\Mount\IMountPoint;
use OCP\ICacheFactory;
use OCP\IBinaryFinder;
use OCP\IConfig;
use OCP\IUser;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -486,6 +487,15 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
$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;
Expand Down

0 comments on commit 8219813

Please sign in to comment.