diff --git a/src/Jobs/ProcessAnnotatedFile.php b/src/Jobs/ProcessAnnotatedFile.php index 44af67c..9f383be 100644 --- a/src/Jobs/ProcessAnnotatedFile.php +++ b/src/Jobs/ProcessAnnotatedFile.php @@ -128,12 +128,12 @@ public function handle() ->onQueue($this->queue) ->delay(60); } catch (Exception $e) { - if ($this->shouldGiveUpAfterException($e)) { - $class = get_class($this->file); - Log::warning("Could not process annotated {$class} {$this->file->id}: {$e->getMessage()}", ['exception' => $e]); - } elseif ($this->shouldRetryAfterException($e)) { + if ($this->shouldRetryAfterException($e)) { // Exponential backoff for retry after 10 and then 20 minutes. $this->release($this->attempts() * 600); + } elseif ($this->shouldGiveUpAfterException($e)) { + $class = get_class($this->file); + Log::warning("Could not process annotated {$class} {$this->file->id}: {$e->getMessage()}", ['exception' => $e]); } else { $class = get_class($this->file); throw new ProcessAnnotatedFileException("Could not process annotated {$class} {$this->file->id}.", previous: $e); @@ -161,7 +161,9 @@ protected function shouldGiveUpAfterException(Exception $e): bool $giveUpError = ( // SSL certificate problem of the remote server. // See: https://curl.haxx.se/libcurl/c/libcurl-errors.html - Str::contains($message, 'cURL error 60:') + Str::contains($message, 'cURL error 60:') || + // File not found. + Str::contains($message, 'Unable to read file from location:') ); return $giveUpError; diff --git a/tests/Jobs/ProcessAnnotatedImageTest.php b/tests/Jobs/ProcessAnnotatedImageTest.php index 7676b88..2f30bc2 100644 --- a/tests/Jobs/ProcessAnnotatedImageTest.php +++ b/tests/Jobs/ProcessAnnotatedImageTest.php @@ -394,6 +394,7 @@ public function testHandleGiveUpError() $annotation = ImageAnnotationTest::create(); $job = new ProcessAnnotatedImage($annotation->image); + $job->tries = 1; $job->handle(); $prefix = fragment_uuid_path($annotation->image->uuid); $disk->assertMissing("{$prefix}/{$annotation->id}.svg"); diff --git a/tests/Jobs/ProcessAnnotatedVideoTest.php b/tests/Jobs/ProcessAnnotatedVideoTest.php index 420bc53..0107b0b 100644 --- a/tests/Jobs/ProcessAnnotatedVideoTest.php +++ b/tests/Jobs/ProcessAnnotatedVideoTest.php @@ -437,6 +437,7 @@ public function testHandleGiveUpError() $annotation = VideoAnnotationTest::create(); $job = new ProcessAnnotatedVideo($annotation->video); + $job->tries = 1; $job->handle(); $prefix = fragment_uuid_path($annotation->video->uuid); $disk->assertMissing("{$prefix}/v-{$annotation->id}.svg");