diff --git a/lib/Listener/FileListener.php b/lib/Listener/FileListener.php index d3a0d55..3d3e9d7 100644 --- a/lib/Listener/FileListener.php +++ b/lib/Listener/FileListener.php @@ -116,7 +116,7 @@ public function handle(Event $event): void { if ($event instanceof \OCP\Files\Config\Event\UserMountAddedEvent) { $rootId = $event->mountPoint->getRootId(); // Asynchronous, because we potentially recurse and this event needs to be handled fast - $this->fsEventScheduler->onAccessUpdateDecl($rootId); + $this->fsEventScheduler->onAccessUpdateDecl($rootId, $event->mountPoint->getUser()->getUID()); // Remember that this mount was added in the current process (see UserMountRemovedEvent below) $this->addedMounts[$event->mountPoint->getUser()->getUID() . '-' . $rootId] = true; } @@ -130,7 +130,7 @@ public function handle(Event $event): void { return; } // Asynchronous, because we potentially recurse and this event needs to be handled fast - $this->fsEventScheduler->onAccessUpdateDecl($rootId); + $this->fsEventScheduler->onAccessUpdateDecl($rootId, $event->mountPoint->getUser()->getUID()); } } catch (InvalidPathException|Exception|NotFoundException $e) { $this->logger->warning('Error in fs event listener: ' . $e->getMessage(), ['exception' => $e]); diff --git a/lib/Service/FsEventScheduler.php b/lib/Service/FsEventScheduler.php index e968e40..acb4093 100644 --- a/lib/Service/FsEventScheduler.php +++ b/lib/Service/FsEventScheduler.php @@ -63,10 +63,12 @@ private function retractEvent(FsEventType $type, string $ownerId, int $nodeId) { * @throws NotFoundException * @throws Exception */ - public function onAccessUpdateDecl(int $nodeId): void { - $ownerId = $this->storageService->getOwnerForFileId($nodeId); - if ($ownerId === false) { - throw new NotFoundException('Cannot get owner for file ID ' . $nodeId); + public function onAccessUpdateDecl(int $nodeId, ?string $ownerId = null): void { + if ($ownerId === null) { + $ownerId = $this->storageService->getOwnerForFileId($nodeId); + if ($ownerId === false) { + throw new NotFoundException('Cannot get owner for file ID ' . $nodeId); + } } $this->scheduleEvent(FsEventType::ACCESS_UPDATE_DECL, $ownerId, $nodeId); }