Skip to content

Commit

Permalink
IndexerJob: Avoid sending the same resource multiple times
Browse files Browse the repository at this point in the history
After the first time it is consumed, it will be closed

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr authored Mar 22, 2024
1 parent 5d0e6a2 commit 0c52d7b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/BackgroundJobs/IndexerJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,19 @@ protected function index(array $files): void {
if (!$file instanceof File) {
continue;
}
try {
$fileHandle = $file->fopen('r');
} catch (LockedException|NotPermittedException $e) {
$this->logger->error('Could not open file ' . $file->getPath() . ' for reading', ['exception' => $e]);
continue;
}
$userIds = $this->storageService->getUsersForFileId($queueFile->getFileId());
foreach ($userIds as $userId) {
try {
try {
$fileHandle = $file->fopen('r');
} catch (LockedException|NotPermittedException $e) {
$this->logger->error('Could not open file ' . $file->getPath() . ' for reading', ['exception' => $e]);
continue 2;
}
if (!is_resource($fileHandle)) {
$this->logger->warning('File handle for' . $file->getPath() . ' is not readable');
continue;
}
$source = new Source(
$userId,
ProviderService::getSourceId($file->getId()),
Expand Down

0 comments on commit 0c52d7b

Please sign in to comment.