-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathQuota.php
49 lines (40 loc) Β· 1.46 KB
/
Quota.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\GroupFolders\Command;
use OCP\Files\FileInfo;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Quota extends FolderCommand {
protected function configure(): void {
$this
->setName('groupfolders:quota')
->setDescription('Edit the quota of a configured Team folder')
->addArgument('folder_id', InputArgument::REQUIRED, 'Id of the folder to configure')
->addArgument('quota', InputArgument::REQUIRED, 'New value for the quota of the folder');
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$folder = $this->getFolder($input, $output);
if ($folder === null) {
return -1;
}
$quotaString = $input->getArgument('quota');
if (!is_string($quotaString)) {
$output->writeln('<error><quota> argument has to be a string</error>');
return -3;
}
$quotaString = strtolower($quotaString);
$quota = ($quotaString === 'unlimited') ? FileInfo::SPACE_UNLIMITED : \OCP\Util::computerFileSize($quotaString);
if ($quota) {
$this->folderManager->setFolderQuota($folder['id'], (int)$quota);
return 0;
}
$output->writeln('<error>Unable to parse quota input: ' . $quotaString . '</error>');
return -1;
}
}