diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2022-05-17 11:38:11 +0300 |
---|---|---|
committer | Richard Steinmetz <richard@steinmetz.cloud> | 2022-05-17 11:38:24 +0300 |
commit | 36291eee73b741a8946f25e51ddb5af088f42969 (patch) | |
tree | 0097db0db08d8ff0412a1ed5e35735464dc956aa | |
parent | 3f5b3377ea699d47163116ce94d94aa5834fbda8 (diff) |
Drop ancient DeleteOld command
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
-rw-r--r-- | appinfo/info.xml | 1 | ||||
-rw-r--r-- | lib/Command/DeleteOld.php | 98 |
2 files changed, 0 insertions, 99 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml index fc602e0..e440c7d 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -29,7 +29,6 @@ The first time you install this app, before using a cron job, you properly want <commands> <command>OCA\PreviewGenerator\Command\Generate</command> - <command>OCA\PreviewGenerator\Command\DeleteOld</command> <command>OCA\PreviewGenerator\Command\PreGenerate</command> </commands> </info> diff --git a/lib/Command/DeleteOld.php b/lib/Command/DeleteOld.php deleted file mode 100644 index 464f93e..0000000 --- a/lib/Command/DeleteOld.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl> - * - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -namespace OCA\PreviewGenerator\Command; - -use OCP\Files\Folder; -use OCP\Files\IRootFolder; -use OCP\Files\NotFoundException; -use OCP\IUser; -use OCP\IUserManager; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -class DeleteOld extends Command { - - /** @var IUserManager */ - protected $userManager; - - /** @var IRootFolder */ - protected $rootFolder; - - public function __construct(IRootFolder $rootFolder, - IUserManager $userManager) { - parent::__construct(); - - $this->userManager = $userManager; - $this->rootFolder = $rootFolder; - } - - protected function configure() { - $this - ->setName('preview:delete_old') - ->setDescription('Delete old preview folder (pre NC11)') - ->addArgument( - 'user_id', - InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - 'Delete old preview folder for the given user(s)' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): int { - $userIds = $input->getArgument('user_id'); - - if (count($userIds) === 0) { - $this->userManager->callForSeenUsers(function (IUser $user) { - $this->deletePreviews($user); - }); - } else { - foreach ($userIds as $userId) { - $user = $this->userManager->get($userId); - if ($user !== null) { - $this->deletePreviews($user); - } - } - } - - return 0; - } - - private function deletePreviews(IUser $user) { - \OC_Util::tearDownFS(); - \OC_Util::setupFS($user->getUID()); - - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); - $userRoot = $userFolder->getParent(); - - try { - /** @var Folder $thumbnails */ - $thumbnails = $userRoot->get('thumbnails'); - $thumbnails->delete(); - } catch (NotFoundException $e) { - //Ignore - } - } -} |