mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Merge pull request #22554 from nextcloud/backport/22528/stable18
[stable18] Change free space calculation
This commit is contained in:
commit
95c6a9124e
2 changed files with 18 additions and 6 deletions
|
|
@ -712,11 +712,13 @@ class Trashbin {
|
|||
*/
|
||||
private static function calculateFreeSpace($trashbinSize, $user) {
|
||||
$config = \OC::$server->getConfig();
|
||||
$systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
|
||||
$userTrashbinSize = (int)$config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
|
||||
$configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize;
|
||||
if ($configuredTrashbinSize) {
|
||||
return $configuredTrashbinSize - $trashbinSize;
|
||||
if ($userTrashbinSize > -1) {
|
||||
return $userTrashbinSize - $trashbinSize;
|
||||
}
|
||||
$systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
|
||||
if ($systemTrashbinSize > -1) {
|
||||
return $systemTrashbinSize - $trashbinSize;
|
||||
}
|
||||
|
||||
$softQuota = true;
|
||||
|
|
|
|||
|
|
@ -120,15 +120,25 @@ class TrashbinTest extends \Test\TestCase {
|
|||
\OC::$server->getAppManager()->enableApp('files_trashbin');
|
||||
$config = \OC::$server->getConfig();
|
||||
$mockConfig = $this->createMock(\OCP\IConfig::class);
|
||||
$mockConfig->expects($this->any())
|
||||
$mockConfig
|
||||
->method('getSystemValue')
|
||||
->will($this->returnCallback(function ($key, $default) use ($config) {
|
||||
->will($this->returnCallback(static function ($key, $default) use ($config) {
|
||||
if ($key === 'filesystem_check_changes') {
|
||||
return \OC\Files\Cache\Watcher::CHECK_ONCE;
|
||||
} else {
|
||||
return $config->getSystemValue($key, $default);
|
||||
}
|
||||
}));
|
||||
$mockConfig
|
||||
->method('getUserValue')
|
||||
->willReturnCallback(static function ($userId, $appName, $key, $default = '') use ($config) {
|
||||
return $config->getUserValue($userId, $appName, $key, $default);
|
||||
});
|
||||
$mockConfig
|
||||
->method('getAppValue')
|
||||
->willReturnCallback(static function ($appName, $key, $default = '') use ($config) {
|
||||
return $config->getAppValue($appName, $key, $default);
|
||||
});
|
||||
$this->overwriteService('AllConfig', $mockConfig);
|
||||
|
||||
$this->trashRoot1 = '/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin';
|
||||
|
|
|
|||
Loading…
Reference in a new issue