diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index d88710e4e191f..3ea440a885a68 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -21,6 +21,7 @@ use OCP\Share\IAttributes; use OCP\Share\IManager; use OCP\Share\IShare; +use OCP\User\Exceptions\UserNotFoundException; use Override; class Share implements IShare { @@ -135,20 +136,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); - } - - $node = $userFolder->getFirstNodeById($this->fileId); - if (!$node) { - throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId); + 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 (UserNotFoundException $e) { + throw new NotFoundException('Owner for share not found, fileid: ' . $this->fileId, previous:$e); } - - $this->node = $node; } return $this->node;