From 22870a2ae668a5410c7bda231132a03e2b28cff7 Mon Sep 17 00:00:00 2001 From: Arne Hamann Date: Tue, 29 Aug 2023 12:30:02 +0200 Subject: [PATCH] Command for registering maps mimetypes Signed-off-by: Arne Hamann --- appinfo/info.xml | 1 + lib/Command/RegisterMimetypes.php | 56 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 lib/Command/RegisterMimetypes.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 548665bd5..e548ab264 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -51,6 +51,7 @@ OCA\Maps\Command\RescanPhotos OCA\Maps\Command\RescanTracks + OCA\Maps\Command\RegisterMimetypes OCA\Maps\Settings\AdminSettings diff --git a/lib/Command/RegisterMimetypes.php b/lib/Command/RegisterMimetypes.php new file mode 100644 index 000000000..cda773c96 --- /dev/null +++ b/lib/Command/RegisterMimetypes.php @@ -0,0 +1,56 @@ + + * @copyright Piotr Bator 2017 + */ + +namespace OCA\Maps\Command; + +use OCA\Maps\Service\MimetypeService; +use OCP\Encryption\IManager; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputOption; +use OCP\IConfig; + +use OCA\Maps\Service\PhotofilesService; + +class RegisterMimetypes extends Command { + + protected $mimetypeService; + + public function __construct(MimetypeService $mimetypeService) { + parent::__construct(); + $this->mimetypeService = $mimetypeService; + } + + /** + * @return void + */ + protected function configure() { + $this->setName('maps:register-mimetypes') + ->setDescription('Registers the maps mimetypes for existing and new files.'); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int { + $this->output = $output; + $output->writeln("Register mimetypes for existing files"); + $this->mimetypeService->registerForExistingFiles(); + $output->writeln("Register mimetypes for new files"); + $this->mimetypeService->registerForNewFiles(); + return 0; + } +}