Skip to content

Commit

Permalink
fix(FileListener): Implement ShareDeletedEvent handler
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Nov 22, 2023
1 parent 27c4271 commit 42a7cbd
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions lib/Listener/FileListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,39 @@ public function handle(Event $event): void {
}
$files = $this->storageService->getFilesInMount($mount->getNumericStorageId(), $node->getId(), 0, 0);
foreach ($files as $fileId) {
$this->postInsert(current($this->rootFolder->getById($fileId)), false, true);
$node = current($this->rootFolder->getById($fileId));
try {
$fileHandle = $node->fopen('r');

Check failure on line 120 in lib/Listener/FileListener.php

View workflow job for this annotation

GitHub Actions / Nextcloud (8.1, dev-master)

UndefinedInterfaceMethod

lib/Listener/FileListener.php:120:28: UndefinedInterfaceMethod: Method OCP\Files\Node::fopen does not exist (see https://psalm.dev/181)

Check failure on line 120 in lib/Listener/FileListener.php

View workflow job for this annotation

GitHub Actions / Nextcloud (8.2, dev-master)

UndefinedInterfaceMethod

lib/Listener/FileListener.php:120:28: UndefinedInterfaceMethod: Method OCP\Files\Node::fopen does not exist (see https://psalm.dev/181)
} catch (LockedException|NotPermittedException $e) {
$this->logger->error('Could not open file ' . $node->getPath() . ' for reading', ['exception' => $e]);
return;
}
foreach ($userIds as $userId) {
try {
$source = new Source($userId, 'file: ' . $node->getId(), $fileHandle, $node->getMtime(), $node->getMimeType());
} catch (InvalidPathException|NotFoundException $e) {
$this->logger->error('Could not find file ' . $node->getPath(), ['exception' => $e]);
break;
}
$this->langRopeService->deleteSources($userId, [$source]);
}
}
} else {
// TODO: remove index entry of $node for $userIds
try {
$fileHandle = $node->fopen('r');
} catch (LockedException|NotPermittedException $e) {
$this->logger->error('Could not open file ' . $node->getPath() . ' for reading', ['exception' => $e]);
return;
}
foreach ($userIds as $userId) {
try {
$source = new Source($userId, 'file: ' . $node->getId(), $fileHandle, $node->getMtime(), $node->getMimeType());
} catch (InvalidPathException|NotFoundException $e) {
$this->logger->error('Could not find file ' . $node->getPath(), ['exception' => $e]);
break;
}
$this->langRopeService->deleteSources($userId, [$source]);
}
}
}
if ($event instanceof BeforeNodeDeletedEvent) {
Expand Down

0 comments on commit 42a7cbd

Please sign in to comment.