From f6e644b43fe3c33ba298ee34a73536c85cc92b4a Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 20 Jan 2015 19:45:32 +0100 Subject: Catch storage exception in scanner for remote shares Whenever an exception occurs during scan of a remote share, the share is checked for availability. If the storage is gone, it will be removed automatically. Also, getDirectoryContent() will now skip unavailable storages. --- lib/private/files/view.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/private/files/view.php') diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 76b7d34e756..fd2ba11d30b 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1037,7 +1037,22 @@ class View { if ($subCache->getStatus('') === Cache\Cache::NOT_FOUND) { $subScanner = $subStorage->getScanner(''); - $subScanner->scanFile(''); + try { + $subScanner->scanFile(''); + } catch (\OCP\Files\StorageNotAvailableException $e) { + continue; + } catch (\OCP\Files\StorageInvalidException $e) { + continue; + } catch (\Exception $e) { + // sometimes when the storage is not available it can be any exception + \OCP\Util::writeLog( + 'core', + 'Exception while scanning storage "' . $subStorage->getId() . '": ' . + get_class($e) . ': ' . $e->getMessage(), + \OC_Log::ERROR + ); + continue; + } } $rootEntry = $subCache->get(''); -- cgit v1.2.3