From 0b8e1adec1bb2ada8cd6f1d8638a067351e11386 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 3 Sep 2024 14:00:46 +0200 Subject: [PATCH] fix(settings): Calculate correct default quota option sizes Signed-off-by: provokateurin --- appinfo/info.xml | 8 ++- lib/Migration/WrongDefaultQuotaRepairStep.php | 50 +++++++++++++++++++ src/settings/App.tsx | 7 +-- 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 lib/Migration/WrongDefaultQuotaRepairStep.php diff --git a/appinfo/info.xml b/appinfo/info.xml index e92580c7e..dc502f6fc 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -10,7 +10,7 @@ Folders can be configured from *Group folders* in the admin settings. After a folder is created, the admin can give access to the folder to one or more groups, control their write/sharing permissions and assign a quota for the folder. Note: Encrypting the contents of group folders is currently not supported.]]> - 17.0.3 + 17.0.4 agpl Robin Appelman GroupFolders @@ -38,6 +38,12 @@ Note: Encrypting the contents of group folders is currently not supported.]]>OCA\GroupFolders\BackgroundJob\ExpireGroupTrash + + + OCA\GroupFolders\Migration\WrongDefaultQuotaRepairStep + + + OCA\GroupFolders\Command\ExpireGroup\ExpireGroupBase OCA\GroupFolders\Command\ListCommand diff --git a/lib/Migration/WrongDefaultQuotaRepairStep.php b/lib/Migration/WrongDefaultQuotaRepairStep.php new file mode 100644 index 000000000..300a4ec82 --- /dev/null +++ b/lib/Migration/WrongDefaultQuotaRepairStep.php @@ -0,0 +1,50 @@ +manager->getAllFolders() as $id => $folder) { + $quota = $folder['quota']; + + $changed = false; + if ($quota === 1073741274) { + $quota = 1024 ** 3; + $changed = true; + } elseif ($quota === 10737412742) { + $quota = 1024 ** 3 * 10; + $changed = true; + } + + if ($changed) { + $this->manager->setFolderQuota($id, $quota); + } + } + } +} diff --git a/src/settings/App.tsx b/src/settings/App.tsx index 1d94287d2..b5a500078 100644 --- a/src/settings/App.tsx +++ b/src/settings/App.tsx @@ -14,10 +14,11 @@ import AdminGroupSelect from './AdminGroupSelect' import SubAdminGroupSelect from './SubAdminGroupSelect' import { loadState } from '@nextcloud/initial-state' +const bytesInOneGibibyte = Math.pow(1024, 3) const defaultQuotaOptions = { - '1 GB': 1073741274, - '5 GB': 5368709120, - '10 GB': 10737412742, + '1 GB': bytesInOneGibibyte, + '5 GB': bytesInOneGibibyte * 5, + '10 GB': bytesInOneGibibyte * 10, Unlimited: -3, }