-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathExpireGroupVersionsTrash.php
43 lines (35 loc) Β· 1.28 KB
/
ExpireGroupVersionsTrash.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
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\GroupFolders\Command\ExpireGroup;
use OCA\Files_Trashbin\Expiration;
use OCA\GroupFolders\Trash\TrashBackend;
use OCA\GroupFolders\Versions\GroupVersionsExpireManager;
use OCP\EventDispatcher\IEventDispatcher;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ExpireGroupVersionsTrash extends ExpireGroupVersions {
public function __construct(
GroupVersionsExpireManager $expireManager,
IEventDispatcher $eventDispatcher,
private readonly TrashBackend $trashBackend,
private readonly Expiration $expiration,
) {
parent::__construct($expireManager, $eventDispatcher);
}
protected function configure(): void {
parent::configure();
$this
->setName('groupfolders:expire')
->setDescription('Trigger expiry of versions and trashbin for files stored in group folders');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
parent::execute($input, $output);
[$count, $size] = $this->trashBackend->expire($this->expiration);
$output->writeln("<info>Removed $count expired trashbin items</info>");
return 0;
}
}