Skip to content

Commit

Permalink
fixed some issues with IncrementalIndexer
Browse files Browse the repository at this point in the history
  • Loading branch information
pushrbx authored Nov 8, 2024
1 parent cc5c12f commit a87b461
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/Console/Commands/Indexer/IncrementalIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ private function fetchIds(string $mediaType, array $idsToFetch, bool $resume): v
$this->info("Resuming from index: $index");
}

if ($index > 0 && !isset($this->ids[$index]))
$ids = array_merge($idsToFetch['sfw'], $idsToFetch['nsfw']);

if ($index > 0 && !isset($ids[$index]))
{
$index = 0;
$this->warn('Invalid index; set back to 0');
Expand All @@ -112,7 +114,6 @@ private function fetchIds(string $mediaType, array $idsToFetch, bool $resume): v
Storage::put("indexer/incremental/{$mediaType}_resume.save", 0);

$this->info("$idCount $mediaType entries available");
$ids = array_merge($idsToFetch['sfw'], $idsToFetch['nsfw']);

for ($i = $index; $i <= ($idCount - 1); $i++)
{
Expand Down Expand Up @@ -184,7 +185,7 @@ public function handle(): int
}

// we want to handle signals from the OS
$this->trap(SIGTERM, fn () => $this->cancelled = true);
$this->trap([SIGTERM, SIGQUIT, SIGINT], fn () => $this->cancelled = true);

$resume = $this->option('resume') ?? false;
$onlyFailed = $this->option('failed') ?? false;
Expand All @@ -208,13 +209,14 @@ public function handle(): int
$idsToFetch = $this->getIdsToFetch($mediaType);
}

if ($this->cancelled)
{
return 127;
}

$idCount = count($idsToFetch);
if ($idCount == 0)
if ($idCount === 0)
{
if ($this->cancelled)
{
return 127;
}
continue;
}

Expand Down

0 comments on commit a87b461

Please sign in to comment.