mirror of
https://github.com/nextcloud/server.git
synced 2025-04-13 21:09:42 +00:00
feat(files): add command to (dis)enable windows compatible filenames
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
6a25f92bb8
commit
0f0846f9dd
4 changed files with 53 additions and 0 deletions
apps/files
appinfo
composer/composer
lib/Command
|
@ -53,6 +53,7 @@
|
|||
<command>OCA\Files\Command\Object\Info</command>
|
||||
<command>OCA\Files\Command\Object\ListObject</command>
|
||||
<command>OCA\Files\Command\Object\Orphans</command>
|
||||
<command>OCA\Files\Command\WindowsCompatibleFilenames</command>
|
||||
</commands>
|
||||
|
||||
<settings>
|
||||
|
|
|
@ -46,6 +46,7 @@ return array(
|
|||
'OCA\\Files\\Command\\Scan' => $baseDir . '/../lib/Command/Scan.php',
|
||||
'OCA\\Files\\Command\\ScanAppData' => $baseDir . '/../lib/Command/ScanAppData.php',
|
||||
'OCA\\Files\\Command\\TransferOwnership' => $baseDir . '/../lib/Command/TransferOwnership.php',
|
||||
'OCA\\Files\\Command\\WindowsCompatibleFilenames' => $baseDir . '/../lib/Command/WindowsCompatibleFilenames.php',
|
||||
'OCA\\Files\\Controller\\ApiController' => $baseDir . '/../lib/Controller/ApiController.php',
|
||||
'OCA\\Files\\Controller\\ConversionApiController' => $baseDir . '/../lib/Controller/ConversionApiController.php',
|
||||
'OCA\\Files\\Controller\\DirectEditingController' => $baseDir . '/../lib/Controller/DirectEditingController.php',
|
||||
|
|
|
@ -61,6 +61,7 @@ class ComposerStaticInitFiles
|
|||
'OCA\\Files\\Command\\Scan' => __DIR__ . '/..' . '/../lib/Command/Scan.php',
|
||||
'OCA\\Files\\Command\\ScanAppData' => __DIR__ . '/..' . '/../lib/Command/ScanAppData.php',
|
||||
'OCA\\Files\\Command\\TransferOwnership' => __DIR__ . '/..' . '/../lib/Command/TransferOwnership.php',
|
||||
'OCA\\Files\\Command\\WindowsCompatibleFilenames' => __DIR__ . '/..' . '/../lib/Command/WindowsCompatibleFilenames.php',
|
||||
'OCA\\Files\\Controller\\ApiController' => __DIR__ . '/..' . '/../lib/Controller/ApiController.php',
|
||||
'OCA\\Files\\Controller\\ConversionApiController' => __DIR__ . '/..' . '/../lib/Controller/ConversionApiController.php',
|
||||
'OCA\\Files\\Controller\\DirectEditingController' => __DIR__ . '/..' . '/../lib/Controller/DirectEditingController.php',
|
||||
|
|
50
apps/files/lib/Command/WindowsCompatibleFilenames.php
Normal file
50
apps/files/lib/Command/WindowsCompatibleFilenames.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
namespace OCA\Files\Command;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Files\Service\SettingsService;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class WindowsCompatibleFilenames extends Base {
|
||||
|
||||
public function __construct(
|
||||
private SettingsService $service,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void {
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('files:windows-compatible-filenames')
|
||||
->setDescription('Enforce naming constraints for windows compatible filenames')
|
||||
->addOption('enable', description: 'Enable windows naming constraints')
|
||||
->addOption('disable', description: 'Disable windows naming constraints');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
if ($input->getOption('enable')) {
|
||||
if ($this->service->hasFilesWindowsSupport()) {
|
||||
$output->writeln('<error>Windows compatible filenames already enforced.</error>', OutputInterface::VERBOSITY_VERBOSE);
|
||||
}
|
||||
$this->service->setFilesWindowsSupport(true);
|
||||
$output->writeln('Windows compatible filenames enforced.');
|
||||
} elseif ($input->getOption('disable')) {
|
||||
if (!$this->service->hasFilesWindowsSupport()) {
|
||||
$output->writeln('<error>Windows compatible filenames already disabled.</error>', OutputInterface::VERBOSITY_VERBOSE);
|
||||
}
|
||||
$this->service->setFilesWindowsSupport(false);
|
||||
$output->writeln('Windows compatible filename constraints removed.');
|
||||
} else {
|
||||
$output->writeln('Windows compatible filenames are ' . ($this->service->hasFilesWindowsSupport() ? 'enforced' : 'disabled'));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue