summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-03-20 03:22:58 -0600
committerGitHub <noreply@github.com>2017-03-20 03:22:58 -0600
commit8b670b41f11667934e4291d2dae80dd552ff14ed (patch)
tree4e262a18e6680617f51cadf724b1aa9f109a634a
parentc969d8005e45ed3996577005a3778e6c88c0f6b8 (diff)
parent81c1522ad0c894afd13b749775b537f7dd30711f (diff)
downloadnextcloud-server-8b670b41f11667934e4291d2dae80dd552ff14ed.tar.gz
nextcloud-server-8b670b41f11667934e4291d2dae80dd552ff14ed.zip
Merge pull request #3952 from nextcloud/downstream-27209
Log files:scan exception, add InterruptedException
-rw-r--r--apps/files/lib/Command/Scan.php18
-rw-r--r--core/Command/InterruptedException.php26
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
4 files changed, 38 insertions, 8 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php
index 0234fb435a7..24b47aca9a4 100644
--- a/apps/files/lib/Command/Scan.php
+++ b/apps/files/lib/Command/Scan.php
@@ -30,6 +30,7 @@ namespace OCA\Files\Command;
use Doctrine\DBAL\Connection;
use OC\Core\Command\Base;
+use OC\Core\Command\InterruptedException;
use OC\ForbiddenException;
use OCP\Files\StorageNotAvailableException;
use OCP\IDBConnection;
@@ -117,14 +118,14 @@ class Scan extends Base {
$output->writeln("\tFile <info>$path</info>");
$this->filesCounter += 1;
if ($this->hasBeenInterrupted()) {
- throw new \Exception('ctrl-c');
+ throw new InterruptedException();
}
});
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
$output->writeln("\tFolder <info>$path</info>");
$this->foldersCounter += 1;
if ($this->hasBeenInterrupted()) {
- throw new \Exception('ctrl-c');
+ throw new InterruptedException();
}
});
$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
@@ -135,13 +136,13 @@ class Scan extends Base {
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
$this->filesCounter += 1;
if ($this->hasBeenInterrupted()) {
- throw new \Exception('ctrl-c');
+ throw new InterruptedException();
}
});
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
$this->foldersCounter += 1;
if ($this->hasBeenInterrupted()) {
- throw new \Exception('ctrl-c');
+ throw new InterruptedException();
}
});
}
@@ -161,11 +162,12 @@ class Scan extends Base {
} catch (ForbiddenException $e) {
$output->writeln("<error>Home storage for user $user not writable</error>");
$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
+ $output->writeln('Interrupted by user');
} catch (\Exception $e) {
- if ($e->getMessage() !== 'ctrl-c') {
- $output->writeln('<error>Exception while scanning: ' . $e->getMessage() . "\n" . $e->getTraceAsString() . '</error>');
- }
- return;
+ $output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
+ $output->writeln('<error>' . $e->getTraceAsString() . '</error>');
}
}
diff --git a/core/Command/InterruptedException.php b/core/Command/InterruptedException.php
new file mode 100644
index 00000000000..ef81b5d9393
--- /dev/null
+++ b/core/Command/InterruptedException.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * @author Vincent Petry <pvince81@owncloud.com>
+ *
+ * @copyright Copyright (c) 2017, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OC\Core\Command;
+
+/**
+ * Exception for when the user hit ctrl-c
+ */
+class InterruptedException extends \Exception {}
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index c87bcce194f..d0d0898d0bd 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -407,6 +407,7 @@ return array(
'OC\\Core\\Command\\Integrity\\CheckCore' => $baseDir . '/core/Command/Integrity/CheckCore.php',
'OC\\Core\\Command\\Integrity\\SignApp' => $baseDir . '/core/Command/Integrity/SignApp.php',
'OC\\Core\\Command\\Integrity\\SignCore' => $baseDir . '/core/Command/Integrity/SignCore.php',
+ 'OC\\Core\\Command\\InterruptedException' => $baseDir . '/core/Command/InterruptedException.php',
'OC\\Core\\Command\\L10n\\CreateJs' => $baseDir . '/core/Command/L10n/CreateJs.php',
'OC\\Core\\Command\\Log\\File' => $baseDir . '/core/Command/Log/File.php',
'OC\\Core\\Command\\Log\\Manage' => $baseDir . '/core/Command/Log/Manage.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index eb7188b69b3..7b937bd132c 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -437,6 +437,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Core\\Command\\Integrity\\CheckCore' => __DIR__ . '/../../..' . '/core/Command/Integrity/CheckCore.php',
'OC\\Core\\Command\\Integrity\\SignApp' => __DIR__ . '/../../..' . '/core/Command/Integrity/SignApp.php',
'OC\\Core\\Command\\Integrity\\SignCore' => __DIR__ . '/../../..' . '/core/Command/Integrity/SignCore.php',
+ 'OC\\Core\\Command\\InterruptedException' => __DIR__ . '/../../..' . '/core/Command/InterruptedException.php',
'OC\\Core\\Command\\L10n\\CreateJs' => __DIR__ . '/../../..' . '/core/Command/L10n/CreateJs.php',
'OC\\Core\\Command\\Log\\File' => __DIR__ . '/../../..' . '/core/Command/Log/File.php',
'OC\\Core\\Command\\Log\\Manage' => __DIR__ . '/../../..' . '/core/Command/Log/Manage.php',