Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh: db schema change #79

Merged
merged 14 commits into from
Dec 13, 2024
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.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart!

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
Loading