From fa938cdbfc1c276c7086e86d513ab8853d90ac99 Mon Sep 17 00:00:00 2001 From: Luka Trovic Date: Mon, 17 Mar 2025 07:04:36 +0100 Subject: [PATCH] feat: skip expire sharing notify if node deleted Signed-off-by: Luka Trovic --- lib/FilesHooks.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index a10c21950..10958a78a 100644 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -816,7 +816,7 @@ protected function shareWithTeam(string $shareWith, int $fileSource, string $ite * @throws \OCP\Files\NotFoundException */ public function unShare(IShare $share) { - if (in_array($share->getNodeType(), ['file', 'folder'], true)) { + if (in_array($share->getNodeType(), ['file', 'folder'], true) && !$this->isDeletedNode($share->getShareOwner(), $share->getNodeId())) { if ($share->getShareType() === IShare::TYPE_USER) { $this->unshareFromUser($share); } elseif ($share->getShareType() === IShare::TYPE_GROUP) { @@ -1397,4 +1397,14 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array { return $filteredUsers; } + + private function isDeletedNode(string $owner, int $nodeId): bool { + try { + $userFolder = $this->rootFolder->getUserFolder($owner); + $node = $userFolder->getFirstNodeById($nodeId); + return $node === null; + } catch (NotFoundException $e) { + return true; + } + } }