From ce2dba079605204293373652a53627eb50dd39d7 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 19 Apr 2017 14:36:38 +0200 Subject: show error when trying to scan non existing path Signed-off-by: Robin Appelman --- lib/private/Files/Utils/Scanner.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/private') diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index e76f3225c3c..f845ac31fe2 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -32,6 +32,7 @@ use OC\ForbiddenException; use OC\Hooks\PublicEmitter; use OC\Lock\DBLockingProvider; use OCA\Files_Sharing\SharedStorage; +use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\ILogger; @@ -216,6 +217,9 @@ class Scanner extends PublicEmitter { try { $propagator = $storage->getPropagator(); $propagator->beginBatch(); + if (!$storage->file_exists($relativePath)) { + throw new NotFoundException($dir); + } $scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); $cache = $storage->getCache(); if ($cache instanceof Cache) { -- cgit v1.2.3 From fbedea08076355f9c94b7aa4d14f6157749a4fe7 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 19 Apr 2017 17:04:16 -0500 Subject: Add PHPDoc and handle exception in ScanAppData as well Signed-off-by: Morris Jobke --- apps/files/lib/Command/ScanAppData.php | 2 ++ lib/private/Files/Utils/Scanner.php | 1 + 2 files changed, 3 insertions(+) (limited to 'lib/private') 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('Path not found: ' . $e->getMessage() . ''); } catch (\Exception $e) { $output->writeln('Exception during scan: ' . $e->getMessage() . ''); $output->writeln('' . $e->getTraceAsString() . ''); diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index f845ac31fe2..5d126f2bcc3 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -162,6 +162,7 @@ class Scanner extends PublicEmitter { /** * @param string $dir * @throws \OC\ForbiddenException + * @throws \OCP\Files\NotFoundException */ public function scan($dir = '') { if (!Filesystem::isValidPath($dir)) { -- cgit v1.2.3 From a0e5107c0b01d6ade0fe28f248c418ab5fd95d62 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 20 Apr 2017 13:25:49 +0200 Subject: check for existence before we start the db transaction Signed-off-by: Robin Appelman --- lib/private/Files/Utils/Scanner.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/private') diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 5d126f2bcc3..02f355fd4d9 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -212,15 +212,15 @@ class Scanner extends PublicEmitter { $this->triggerPropagator($storage, $path); }); + if (!$storage->file_exists($relativePath)) { + throw new NotFoundException($dir); + } if (!$isDbLocking) { $this->db->beginTransaction(); } try { $propagator = $storage->getPropagator(); $propagator->beginBatch(); - if (!$storage->file_exists($relativePath)) { - throw new NotFoundException($dir); - } $scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); $cache = $storage->getCache(); if ($cache instanceof Cache) { -- cgit v1.2.3