From 3b207dbf7f0152e8564e3af34637889df30e0266 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 4 Oct 2024 12:49:09 +1000 Subject: [PATCH] Call job::fail() so jobs are put onto the fail queue --- app/Jobs/CatalogDelete.php | 10 ++++++---- app/Jobs/CatalogMove.php | 2 +- app/Jobs/CatalogScan.php | 23 +++++++++++++++-------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/Jobs/CatalogDelete.php b/app/Jobs/CatalogDelete.php index 152e2d2..a084af8 100644 --- a/app/Jobs/CatalogDelete.php +++ b/app/Jobs/CatalogDelete.php @@ -46,12 +46,12 @@ class CatalogDelete implements ShouldQueue * * @return void */ - public function handle() + public function handle(): void { if (! $this->o->remove) { Log::warning(sprintf('%s: NOT Deleting [%s] not marked for deletion',__METHOD__,$this->o->file_name_rel(FALSE))); - exit; + return; } // Remove tags; @@ -63,10 +63,12 @@ class CatalogDelete implements ShouldQueue $this->o->people()->detach(); // Make sure our parent is writable - if (! $this->o->isParentWritable(dirname($this->o->file_name_rel(TRUE)))) { + if (! $this->o->isParentWritable($x=dirname($this->o->file_name_rel(TRUE)))) { Log::warning(sprintf('%s: NOT Deleting [%s] parent directory not writable',__METHOD__,$this->o->file_name(FALSE))); - $this->fail(); + $this->fail('Parent not writable:'.$x); + + return; } // Perform delete diff --git a/app/Jobs/CatalogMove.php b/app/Jobs/CatalogMove.php index d530e6f..827c007 100644 --- a/app/Jobs/CatalogMove.php +++ b/app/Jobs/CatalogMove.php @@ -49,7 +49,7 @@ class CatalogMove implements ShouldQueue,ShouldBeUnique * @return void * @throws \Exception */ - public function handle() + public function handle(): void { $from = $this->o->file_name_rel(); $to = $this->o->file_name_rel(FALSE); diff --git a/app/Jobs/CatalogScan.php b/app/Jobs/CatalogScan.php index 1e1efd5..42f3d96 100644 --- a/app/Jobs/CatalogScan.php +++ b/app/Jobs/CatalogScan.php @@ -49,7 +49,7 @@ class CatalogScan implements ShouldQueue,ShouldBeUnique * @return void * @throws \Exception */ - public function handle() + public function handle(): void { Log::info(sprintf('Scanning [%s] (%d)',$this->o->file_name(FALSE),$this->o->id)); @@ -69,11 +69,13 @@ class CatalogScan implements ShouldQueue,ShouldBeUnique $this->o->getObjectOriginal('height'), $this->o->file_name(FALSE))); - throw new \Exception(sprintf('Dimensions [%s] (%s x %s) mismatch for [%s]', + $this->fail(new \Exception(sprintf('Dimensions [%s] (%s x %s) mismatch for [%s]', $this->o->dimensions, $this->o->getObjectOriginal('width'), $this->o->getObjectOriginal('height'), - $this->o->file_name(FALSE))); + $this->o->file_name(FALSE)))); + + return; } } elseif ($this->o->file_signature) { @@ -82,10 +84,12 @@ class CatalogScan implements ShouldQueue,ShouldBeUnique $this->o->file_signature, $this->o->file_name(FALSE))); - throw new \Exception(sprintf('File Signature [%s] doesnt match [%s] for [%s]', + $this->fail(new \Exception(sprintf('File Signature [%s] doesnt match [%s] for [%s]', $x, $this->o->file_signature, - $this->o->file_name(FALSE))); + $this->o->file_name(FALSE)))); + + return; } $this->o->init(); @@ -120,12 +124,15 @@ class CatalogScan implements ShouldQueue,ShouldBeUnique } // If the file signature changed, abort the update. - if ($this->o->getOriginal('file_signature') && $this->o->wasChanged('file_signature')) - throw new \Exception(sprintf('File Signature Changed for [%s] DB: [%s], File: [%s]?', + if ($this->o->getOriginal('file_signature') && $this->o->wasChanged('file_signature')) { + $this->fail(new \Exception(sprintf('File Signature Changed for [%s] DB: [%s], File: [%s]?', $this->o->file_name(), $this->o->file_signature, $this->o->getOriginal('file_signature'), - )); + ))); + + return; + } $this->o->save(); }