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