From 6b6aef03f78e3efffe78ead41bba1993eea03b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 12 Apr 2021 08:49:25 +0200 Subject: [PATCH] Attempt to fix psalm false-positive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/FilesAppService.php | 5 +++-- lib/Sharing/DeckShareProvider.php | 1 + tests/psalm-baseline.xml | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Service/FilesAppService.php b/lib/Service/FilesAppService.php index aab5fb5cc..53acbaeac 100644 --- a/lib/Service/FilesAppService.php +++ b/lib/Service/FilesAppService.php @@ -35,7 +35,7 @@ use OCP\IDBConnection; use OCP\IL10N; use OCP\IPreview; use OCP\IRequest; -use OCP\Share; +use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IShare; @@ -140,9 +140,10 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService { } public function display(Attachment $attachment) { + /** @psalm-suppress InvalidCatch */ try { $share = $this->shareProvider->getShareById($attachment->getId()); - } catch (Share\Exceptions\ShareNotFound $e) { + } catch (ShareNotFound $e) { throw new NotFoundException('File not found'); } $file = $share->getNode(); diff --git a/lib/Sharing/DeckShareProvider.php b/lib/Sharing/DeckShareProvider.php index 7a992d2af..d9ca09bda 100644 --- a/lib/Sharing/DeckShareProvider.php +++ b/lib/Sharing/DeckShareProvider.php @@ -562,6 +562,7 @@ class DeckShareProvider implements \OCP\Share\IShareProvider { /** * @inheritDoc + * @throws ShareNotFound */ public function getShareById($id, $recipientId = null) { $qb = $this->dbConnection->getQueryBuilder(); diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 20ca6f0f9..7145e7996 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -270,7 +270,7 @@ $this->rootFolder $this->rootFolder IRootFolder - Share\Exceptions\ShareNotFound + ShareNotFound @@ -298,7 +298,7 @@ getSharesInFolder - + GenericShareException GenericShareException ShareNotFound @@ -306,6 +306,7 @@ ShareNotFound ShareNotFound ShareNotFound + ShareNotFound