diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 0d22aa290fad7..0deae776caeea 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -52,6 +52,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\Files\Node; +use OCP\Files\NotFoundException; use OCP\HintException; use OCP\IConfig; use OCP\IGroupManager; @@ -292,10 +293,18 @@ protected function generalCreateChecks(IShare $share) { $permissions = 0; if (!$isFederatedShare && $share->getNode()->getOwner() && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) { - $userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) use ($share) { + try { + $targetNode = $share->getTarget() ? $userFolder->get($share->getTarget()) : null; + } catch (NotFoundException $e) { + $targetNode = null; + } + $userMounts = array_filter($userFolder->getById($share->getNode()->getId()), function ($mount) use ($share, $targetNode) { // We need to filter since there might be other mountpoints that contain the file // e.g. if the user has access to the same external storage that the file is originating from - return $mount->getStorage()->instanceOfStorage(ISharedStorage::class) && $mount->getPath() === $share->getNode()->getPath(); + return $mount->getStorage()->instanceOfStorage(ISharedStorage::class) && ( + $targetNode ? $targetNode->getPath() === $mount->getPath() : + $mount->getPath() === $share->getNode()->getPath() + ); }); $userMount = array_shift($userMounts); if ($userMount === null) {