From 2422dfe6196ade23240d14200056d692bf9118ff Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Sun, 21 Oct 2018 22:06:44 +0200 Subject: Replace $verbose with VERBOSITY_VERBOSE for scanFiles method Signed-off-by: Daniel Kesselberg --- apps/files/lib/Command/ScanAppData.php | 90 ++++++++++------------------------ 1 file changed, 27 insertions(+), 63 deletions(-) (limited to 'apps/files/lib') diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php index 988bcd1e62f..ec4bca43255 100644 --- a/apps/files/lib/Command/ScanAppData.php +++ b/apps/files/lib/Command/ScanAppData.php @@ -33,7 +33,6 @@ use OCP\Files\StorageNotAvailableException; use OCP\IConfig; use OCP\IDBConnection; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Helper\Table; @@ -62,19 +61,7 @@ class ScanAppData extends Base { $this ->setName('files:scan-app-data') - ->setDescription('rescan the AppData folder') - ->addOption( - 'quiet', - 'q', - InputOption::VALUE_NONE, - 'suppress any output' - ) - ->addOption( - 'verbose', - '-v|vv|vvv', - InputOption::VALUE_NONE, - 'verbose the output' - ); + ->setDescription('rescan the AppData folder'); } public function checkScanWarning($fullPath, OutputInterface $output) { @@ -86,7 +73,7 @@ class ScanAppData extends Base { } } - protected function scanFiles($verbose, OutputInterface $output) { + protected function scanFiles(OutputInterface $output) { try { $appData = $this->getAppDataFolder(); } catch (NotFoundException $e) { @@ -96,44 +83,36 @@ class ScanAppData extends Base { $connection = $this->reconnectToDatabase($output); $scanner = new \OC\Files\Utils\Scanner(null, $connection, \OC::$server->getLogger()); + # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception - # printout and count - if ($verbose) { - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { - $output->writeln("\tFile $path"); - $this->filesCounter += 1; - $this->abortIfInterrupted(); - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { - $output->writeln("\tFolder $path"); - $this->foldersCounter += 1; - $this->abortIfInterrupted(); - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) { - $output->writeln('Error while scanning, storage not available (' . $e->getMessage() . ')'); - }); - # count only - } else { - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) { - $this->filesCounter += 1; - $this->abortIfInterrupted(); - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) { - $this->foldersCounter += 1; - $this->abortIfInterrupted(); - }); - } - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) { + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { + $output->writeln("\tFile\t$path", OutputInterface::VERBOSITY_VERBOSE); + ++$this->filesCounter; + $this->abortIfInterrupted(); + }); + + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { + $output->writeln("\tFolder\t$path", OutputInterface::VERBOSITY_VERBOSE); + ++$this->foldersCounter; + $this->abortIfInterrupted(); + }); + + $scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) { + $output->writeln('Error while scanning, storage not available (' . $e->getMessage() . ')', OutputInterface::VERBOSITY_VERBOSE); + }); + + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { $this->checkScanWarning($path, $output); }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) use ($output) { + + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { $this->checkScanWarning($path, $output); }); try { $scanner->scan($appData->getPath()); } catch (ForbiddenException $e) { - $output->writeln("Storage not writable"); + $output->writeln('Storage not writable'); $output->writeln('Make sure you\'re running the scan command only as the user the web server runs as'); } catch (InterruptedException $e) { # exit the function if ctrl-c has been pressed @@ -148,33 +127,19 @@ class ScanAppData extends Base { protected function execute(InputInterface $input, OutputInterface $output) { - # no messaging level option means: no full printout but statistics - # $quiet means no print at all - # $verbose means full printout including statistics - # -q -v full stat - # 0 0 no yes - # 0 1 yes yes - # 1 -- no no (quiet overrules verbose) - $verbose = $input->getOption('verbose'); - $quiet = $input->getOption('quiet'); # restrict the verbosity level to VERBOSITY_VERBOSE if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); } - if ($quiet) { - $verbose = false; - } - $output->writeln("\nScanning AppData for files"); + $output->writeln('Scanning AppData for files'); $this->initTools(); - $this->scanFiles($verbose, $output); + $this->scanFiles($output); + $output->writeln('', OutputInterface::VERBOSITY_VERBOSE); - # stat: printout statistics if $quiet was not set - if (!$quiet) { - $this->presentStats($output); - } + $this->presentStats($output); } /** @@ -213,7 +178,6 @@ class ScanAppData extends Base { protected function presentStats(OutputInterface $output) { // Stop the timer $this->execTime += microtime(true); - $output->writeln(""); $headers = [ 'Folders', 'Files', 'Elapsed time' -- cgit v1.2.3 From 1ad42e8f81dd6f94c205af9cd3b5cb347f803dd4 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Mon, 22 Oct 2018 14:29:49 +0200 Subject: Revert changes not related to $verbose Signed-off-by: Daniel Kesselberg --- apps/files/lib/Command/ScanAppData.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apps/files/lib') diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php index ec4bca43255..04c347afe6b 100644 --- a/apps/files/lib/Command/ScanAppData.php +++ b/apps/files/lib/Command/ScanAppData.php @@ -86,13 +86,13 @@ class ScanAppData extends Base { # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { - $output->writeln("\tFile\t$path", OutputInterface::VERBOSITY_VERBOSE); + $output->writeln("\tFile $path", OutputInterface::VERBOSITY_VERBOSE); ++$this->filesCounter; $this->abortIfInterrupted(); }); $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { - $output->writeln("\tFolder\t$path", OutputInterface::VERBOSITY_VERBOSE); + $output->writeln("\tFolder $path", OutputInterface::VERBOSITY_VERBOSE); ++$this->foldersCounter; $this->abortIfInterrupted(); }); @@ -132,12 +132,11 @@ class ScanAppData extends Base { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); } - $output->writeln('Scanning AppData for files'); + $output->writeln("\nScanning AppData for files"); $this->initTools(); $this->scanFiles($output); - $output->writeln('', OutputInterface::VERBOSITY_VERBOSE); $this->presentStats($output); } @@ -178,6 +177,7 @@ class ScanAppData extends Base { protected function presentStats(OutputInterface $output) { // Stop the timer $this->execTime += microtime(true); + $output->writeln(""); $headers = [ 'Folders', 'Files', 'Elapsed time' -- cgit v1.2.3