Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2020-04-26 21:37:21 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2020-04-26 21:37:21 +0300
commit3294f539426bde8be25c465ff5ccb03c1a05ddf4 (patch)
tree453e6bdb6bcda7175e62eaaa629998e1ce5846c4 /apps
parent797fa188c224132d522710ecda4aa4feb85c3739 (diff)
Set exit code if something went wrong.
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Command/ScanAppData.php32
1 files changed, 20 insertions, 12 deletions
diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php
index 0d34bc1e72c..47cd81e6b4e 100644
--- a/apps/files/lib/Command/ScanAppData.php
+++ b/apps/files/lib/Command/ScanAppData.php
@@ -81,20 +81,20 @@ class ScanAppData extends Base {
}
}
- protected function scanFiles(OutputInterface $output, string $folder) {
+ protected function scanFiles(OutputInterface $output, string $folder): int {
try {
$appData = $this->getAppDataFolder();
} catch (NotFoundException $e) {
- $output->writeln('NoAppData folder found');
- return;
+ $output->writeln('<error>NoAppData folder found</error>');
+ return 1;
}
if ($folder !== '') {
try {
$appData = $appData->get($folder);
} catch (NotFoundException $e) {
- $output->writeln('Could not find folder: ' . $folder);
- return;
+ $output->writeln('<error>Could not find folder: ' . $folder . '</error>');
+ return 1;
}
}
@@ -130,16 +130,22 @@ class ScanAppData extends Base {
$scanner->scan($appData->getPath());
} catch (ForbiddenException $e) {
$output->writeln('<error>Storage not writable</error>');
- $output->writeln('Make sure you\'re running the scan command only as the user the web server runs as');
+ $output->writeln('<info>Make sure you\'re running the scan command only as the user the web server runs as</info>');
+ return 1;
} catch (InterruptedException $e) {
# exit the function if ctrl-c has been pressed
- $output->writeln('Interrupted by user');
+ $output->writeln('<info>Interrupted by user</info>');
+ return 1;
} catch (NotFoundException $e) {
$output->writeln('<error>Path not found: ' . $e->getMessage() . '</error>');
+ return 1;
} catch (\Exception $e) {
$output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
$output->writeln('<error>' . $e->getTraceAsString() . '</error>');
+ return 1;
}
+
+ return 0;
}
@@ -149,15 +155,18 @@ class ScanAppData extends Base {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
- $output->writeln("\nScanning AppData for files");
+ $output->writeln('Scanning AppData for files');
+ $output->writeln('');
$folder = $input->getArgument('folder');
$this->initTools();
- $this->scanFiles($output, $folder);
-
- $this->presentStats($output);
+ $exitCode = $this->scanFiles($output, $folder);
+ if ($exitCode === 0) {
+ $this->presentStats($output);
+ }
+ return $exitCode;
}
/**
@@ -196,7 +205,6 @@ class ScanAppData extends Base {
protected function presentStats(OutputInterface $output) {
// Stop the timer
$this->execTime += microtime(true);
- $output->writeln("");
$headers = [
'Folders', 'Files', 'Elapsed time'