Skip to content

Commit dd122c2

Browse files
authored
Merge pull request #1935 from nextcloud/backport/1915/stable29
[stable29] feat: skip expire sharing notify if node deleted
2 parents 41adcde + d7eeafd commit dd122c2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

lib/FilesHooks.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ protected function shareByLink($fileSource, $itemType, $linkOwner) {
784784
* @throws \OCP\Files\NotFoundException
785785
*/
786786
public function unShare(IShare $share) {
787-
if (in_array($share->getNodeType(), ['file', 'folder'], true)) {
787+
if (in_array($share->getNodeType(), ['file', 'folder'], true) && !$this->isDeletedNode($share->getShareOwner(), $share->getNodeId())) {
788788
if ($share->getShareType() === IShare::TYPE_USER) {
789789
$this->unshareFromUser($share);
790790
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
@@ -1363,4 +1363,14 @@ private function getUnrelatedUsers(int $fileId, array $cachedMounts): array {
13631363

13641364
return $filteredUsers;
13651365
}
1366+
1367+
private function isDeletedNode(string $owner, int $nodeId): bool {
1368+
try {
1369+
$userFolder = $this->rootFolder->getUserFolder($owner);
1370+
$node = $userFolder->getFirstNodeById($nodeId);
1371+
return $node === null;
1372+
} catch (NotFoundException $e) {
1373+
return true;
1374+
}
1375+
}
13661376
}

0 commit comments

Comments
 (0)