Skip to content

Commit

Permalink
add locked files to the end of the index queue
Browse files Browse the repository at this point in the history
Signed-off-by: Anupam Kumar <[email protected]>
  • Loading branch information
kyteinsky committed Dec 12, 2024
1 parent e04be83 commit 42f774a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/BackgroundJobs/IndexerJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ protected function index(array $files): void {
$sources = [];
$allSourceIds = [];
$loadedSources = [];
$retryQFiles = [];
$size = 0;

foreach ($files as $queueFile) {
Expand All @@ -161,9 +162,13 @@ protected function index(array $files): void {
try {
try {
$fileHandle = $file->fopen('r');
} catch (LockedException|NotPermittedException $e) {
} catch (NotPermittedException $e) {
$this->logger->error('Could not open file ' . $file->getPath() . ' for reading', ['exception' => $e]);
continue;
} catch (LockedException $e) {
$retryQFiles[] = $queueFile;
$this->logger->info('File ' . $file->getPath() . ' is locked, could not read for indexing. Adding it to the next batch.');
continue;
}
if (!is_resource($fileHandle)) {
$this->logger->warning('File handle for' . $file->getPath() . ' is not readable');
Expand Down Expand Up @@ -197,6 +202,10 @@ protected function index(array $files): void {

try {
$this->queue->removeFromQueue($files);
// add files that were locked to the end of the queue
foreach ($retryQFiles as $queueFile) {
$this->queue->insertIntoQueue($queueFile);
}
} catch (Exception $e) {
$this->logger->error('Could not remove indexed files from queue', ['exception' => $e]);
}
Expand Down

0 comments on commit 42f774a

Please sign in to comment.