From d7eeafd061b942e48be04dd34065bf437957cc29 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 cceacaf4c..fe099e52d 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -784,7 +784,7 @@ protected function shareByLink($fileSource, $itemType, $linkOwner) { * @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) { @@ -1363,4 +1363,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; + } + } }