diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index 2ededbc7c361a..b87a3d1106530 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -5,8 +5,10 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ + namespace OC\Share20; +use OC\User\NoUserException; use OCP\Constants; use OCP\Files\Cache\ICacheEntry; use OCP\Files\File; @@ -133,20 +135,24 @@ public function getNode(): Node { throw new NotFoundException(); } - // for federated shares the owner can be a remote user, in this - // case we use the initiator - if ($this->userManager->userExists($this->shareOwner)) { - $userFolder = $this->rootFolder->getUserFolder($this->shareOwner); - } else { - $userFolder = $this->rootFolder->getUserFolder($this->sharedBy); + try { + // for federated shares the owner can be a remote user, in this + // case we use the initiator + if ($this->userManager->userExists($this->shareOwner)) { + $userFolder = $this->rootFolder->getUserFolder($this->shareOwner); + } else { + $userFolder = $this->rootFolder->getUserFolder($this->sharedBy); + } + + $node = $userFolder->getFirstNodeById($this->fileId); + if (!$node) { + throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId); + } + + $this->node = $node; + } catch (NoUserException $e) { + throw new NotFoundException('Owner for share not found, fileid: ' . $this->fileId, previous:$e); } - - $node = $userFolder->getFirstNodeById($this->fileId); - if (!$node) { - throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId); - } - - $this->node = $node; } return $this->node;