Skip to content

Commit 4df5d14

Browse files
kyteinskymarcelklehr
authored andcommitted
fix: catch no user backend exceptions and remove those entries
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 3044b0c commit 4df5d14

1 file changed

Lines changed: 25 additions & 28 deletions

File tree

lib/BackgroundJobs/FileSystemListenerJob.php

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,37 @@ protected function run($argument): void {
5252
return;
5353
}
5454

55-
try {
56-
foreach ($fsEvents as $fsEvent) {
57-
$this->diagnosticService->sendHeartbeat(static::class, $this->getId());
55+
foreach ($fsEvents as $fsEvent) {
56+
$this->diagnosticService->sendHeartbeat(static::class, $this->getId());
5857

59-
try {
60-
$node = current($this->rootFolder->getUserFolder($fsEvent->getUserId())->getById($fsEvent->getNodeId()));
61-
if ($node === false) {
62-
$this->logger->warning('Node with ID ' . $fsEvent->getNodeId() . ' not found for fs event "' . $fsEvent->getType() . '"');
63-
$this->fsEventMapper->delete($fsEvent);
64-
continue;
65-
}
58+
try {
59+
$node = current($this->rootFolder->getUserFolder($fsEvent->getUserId())->getById($fsEvent->getNodeId()));
60+
} catch (\Exception $e) {
61+
$this->logger->warning('Error retrieving node for fs event "' . $fsEvent->getType() . '": ' . $e->getMessage(), ['exception' => $e]);
62+
$node = false;
63+
}
64+
if ($node === false) {
65+
$this->logger->warning('Node with ID ' . $fsEvent->getNodeId() . ' not found for fs event "' . $fsEvent->getType() . '"');
66+
$this->fsEventMapper->delete($fsEvent);
67+
continue;
68+
}
6669

67-
switch ($fsEvent->getTypeObject()) {
68-
case FsEventType::CREATE:
69-
$this->fsEventService->onInsert($node);
70-
break;
71-
case FsEventType::ACCESS_UPDATE_DECL:
72-
$this->fsEventService->onAccessUpdateDecl($node);
73-
break;
74-
}
75-
$this->diagnosticService->sendHeartbeat(static::class, $this->getId());
76-
$this->fsEventMapper->delete($fsEvent);
77-
} catch (\RuntimeException $e) {
78-
$this->logger->warning('Error handling fs event "' . $fsEvent->getType() . '": ' . $e->getMessage(), ['exception' => $e]);
70+
try{
71+
switch ($fsEvent->getTypeObject()) {
72+
case FsEventType::CREATE:
73+
$this->fsEventService->onInsert($node);
74+
break;
75+
case FsEventType::ACCESS_UPDATE_DECL:
76+
$this->fsEventService->onAccessUpdateDecl($node);
77+
break;
7978
}
79+
$this->diagnosticService->sendHeartbeat(static::class, $this->getId());
80+
$this->fsEventMapper->delete($fsEvent);
81+
} catch (\RuntimeException $e) {
82+
$this->logger->warning('Error handling fs event "' . $fsEvent->getType() . '": ' . $e->getMessage(), ['exception' => $e]);
8083
}
81-
} catch (\Throwable $e) {
82-
// schedule in 5mins
83-
$this->jobList->scheduleAfter(static::class, $this->time->getTime() + 5 * 60);
84-
throw $e;
8584
}
8685

87-
// schedule in 5mins
88-
$this->jobList->scheduleAfter(static::class, $this->time->getTime() + 5 * 60);
8986
$this->diagnosticService->sendJobEnd(static::class, $this->getId());
9087
}
9188
}

0 commit comments

Comments
 (0)