Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix(settings): Calculate correct default quota option sizes #3167

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.]]></description>
<version>17.0.3</version>
<version>17.0.4</version>
<licence>agpl</licence>
<author>Robin Appelman</author>
<namespace>GroupFolders</namespace>
Expand Down Expand Up @@ -38,6 +38,12 @@ Note: Encrypting the contents of group folders is currently not supported.]]></d
<job>OCA\GroupFolders\BackgroundJob\ExpireGroupTrash</job>
</background-jobs>

<repair-steps>
<post-migration>
<step>OCA\GroupFolders\Migration\WrongDefaultQuotaRepairStep</step>
</post-migration>
</repair-steps>

<commands>
<command>OCA\GroupFolders\Command\ExpireGroup\ExpireGroupBase</command>
<command>OCA\GroupFolders\Command\ListCommand</command>
Expand Down
50 changes: 50 additions & 0 deletions lib/Migration/WrongDefaultQuotaRepairStep.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\GroupFolders\Migration;

use OCA\GroupFolders\Folder\FolderManager;
use OCP\DB\Exception;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class WrongDefaultQuotaRepairStep implements IRepairStep {
public function __construct(
private FolderManager $manager,
) {

}

public function getName() {
return 'Adjust Groupfolders with wrong default quotas';
}

/**
* @param IOutput $output
* @throws Exception
*/
public function run(IOutput $output): void {
foreach ($this->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);
}
}
}
}
7 changes: 4 additions & 3 deletions src/settings/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
Loading