summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-04-21 19:47:33 +0200
committerGitHub <noreply@github.com>2017-04-21 19:47:33 +0200
commit867b3ee234b91ce5fbbbf3b81a5bcce59a0179a3 (patch)
tree50cd7d5390ae88c392628da9d6473c1e31dfb117 /apps
parentd46b155916c4c49fffb5bf8c4391331ce90b44c1 (diff)
parenta0e5107c0b01d6ade0fe28f248c418ab5fd95d62 (diff)
downloadnextcloud-server-867b3ee234b91ce5fbbbf3b81a5bcce59a0179a3.tar.gz
nextcloud-server-867b3ee234b91ce5fbbbf3b81a5bcce59a0179a3.zip
Merge pull request #4396 from nextcloud/scan-non-existing
show error when trying to scan non existing path
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Command/Scan.php19
-rw-r--r--apps/files/lib/Command/ScanAppData.php2
2 files changed, 14 insertions, 7 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php
index 24b47aca9a4..d81beb0eaf3 100644
--- a/apps/files/lib/Command/Scan.php
+++ b/apps/files/lib/Command/Scan.php
@@ -32,6 +32,7 @@ use Doctrine\DBAL\Connection;
use OC\Core\Command\Base;
use OC\Core\Command\InterruptedException;
use OC\ForbiddenException;
+use OCP\Files\NotFoundException;
use OCP\Files\StorageNotAvailableException;
use OCP\IDBConnection;
use OCP\IUserManager;
@@ -131,7 +132,7 @@ class Scan extends Base {
$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
$output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
});
- # count only
+ # count only
} else {
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
$this->filesCounter += 1;
@@ -146,17 +147,17 @@ class Scan extends Base {
}
});
}
- $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) {
+ $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 {
if ($backgroundScan) {
$scanner->backgroundScan($path);
- }else {
+ } else {
$scanner->scan($path);
}
} catch (ForbiddenException $e) {
@@ -165,6 +166,8 @@ class Scan extends Base {
} catch (InterruptedException $e) {
# exit the function if ctrl-c has been pressed
$output->writeln('Interrupted by user');
+ } catch (NotFoundException $e) {
+ $output->writeln('<error>Path not found: ' . $e->getMessage() . '</error>');
} catch (\Exception $e) {
$output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
$output->writeln('<error>' . $e->getTraceAsString() . '</error>');
@@ -194,7 +197,7 @@ class Scan extends Base {
$verbose = $input->getOption('verbose');
$quiet = $input->getOption('quiet');
# restrict the verbosity level to VERBOSITY_VERBOSE
- if ($output->getVerbosity()>OutputInterface::VERBOSITY_VERBOSE) {
+ if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
if ($quiet) {
@@ -223,7 +226,9 @@ class Scan extends Base {
$user_count += 1;
if ($this->userManager->userExists($user)) {
# add an extra line when verbose is set to optical separate users
- if ($verbose) {$output->writeln(""); }
+ if ($verbose) {
+ $output->writeln("");
+ }
$output->writeln("Starting scan for user $user_count out of $users_total ($user)");
# full: printout data if $verbose was set
$this->scanFiles($user, $path, $verbose, $output, $input->getOption('unscanned'));
@@ -327,7 +332,7 @@ class Scan extends Base {
* @return \OCP\IDBConnection
*/
protected function reconnectToDatabase(OutputInterface $output) {
- /** @var Connection | IDBConnection $connection*/
+ /** @var Connection | IDBConnection $connection */
$connection = \OC::$server->getDatabaseConnection();
try {
$connection->close();
diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php
index 365e2e3cb2e..6ad83d9a182 100644
--- a/apps/files/lib/Command/ScanAppData.php
+++ b/apps/files/lib/Command/ScanAppData.php
@@ -128,6 +128,8 @@ class ScanAppData extends Base {
} catch (InterruptedException $e) {
# exit the function if ctrl-c has been pressed
$output->writeln('Interrupted by user');
+ } catch (NotFoundException $e) {
+ $output->writeln('<error>Path not found: ' . $e->getMessage() . '</error>');
} catch (\Exception $e) {
$output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
$output->writeln('<error>' . $e->getTraceAsString() . '</error>');