From b693487d64f088969e94ade99cfab8bd3dd7d6b0 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 17 May 2019 21:04:01 +0200 Subject: [PATCH 1/2] Add catch for RuntimeException getDirectoryListing can throw a NotFoundException or a RuntimeException. The repair step should be skipped if the cache directory is missing so a catch for both exceptions is required. Signed-off-by: Daniel Kesselberg --- lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php index c9c7b5cf1c..92ffcb5474 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -29,6 +29,7 @@ use OCP\IConfig; use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use RuntimeException; /** * Class CleanupCardDAVPhotoCache @@ -63,7 +64,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { private function repair(IOutput $output): void { try { $folders = $this->appData->getDirectoryListing(); - } catch (NotFoundException $e) { + } catch (NotFoundException|RuntimeException $e) { return; } From cbecc1f8cf84b86ec7a8bb8fe358283f915b7965 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 15 Jul 2019 22:26:08 +0200 Subject: [PATCH 2/2] Log RuntimeException in CleanupCardDAVPhotoCache Signed-off-by: Morris Jobke --- lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php index 92ffcb5474..f0e5c2b2a1 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -64,7 +64,10 @@ class CleanupCardDAVPhotoCache implements IRepairStep { private function repair(IOutput $output): void { try { $folders = $this->appData->getDirectoryListing(); - } catch (NotFoundException|RuntimeException $e) { + } catch (NotFoundException $e) { + return; + } catch (RuntimeException $e) { + $this->logger->logException($e, ['message' => 'Failed to fetch directory listing in CleanupCardDAVPhotoCache']); return; }