diff options
author | Vincent Petry <pvince81@owncloud.com> | 2017-02-10 15:24:25 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-03-20 02:24:28 -0600 |
commit | b8a8f43fce979d5ae23d8038daef1ba9b4b48d21 (patch) | |
tree | 97a8e8c1a712da8a9929e1eeacb244767ce58be9 /apps/files/lib/Command | |
parent | 528a903a7b23ea628e6ec2fc9a221821297c0bec (diff) | |
download | nextcloud-server-b8a8f43fce979d5ae23d8038daef1ba9b4b48d21.tar.gz nextcloud-server-b8a8f43fce979d5ae23d8038daef1ba9b4b48d21.zip |
Log files:scan exception, add InterruptedException
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files/lib/Command')
-rw-r--r-- | apps/files/lib/Command/Scan.php | 18 |
1 files changed, 10 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>'); } } |