Call job::fail() so jobs are put onto the fail queue

This commit is contained in:
Deon George 2024-10-04 12:49:09 +10:00
parent 28fdd0fcab
commit 3b207dbf7f
3 changed files with 22 additions and 13 deletions

View File

@ -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

View File

@ -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);

View File

@ -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();
}