From f136360e5c492d331418e5f3dd1b758315a8a992 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 18 Sep 2024 11:50:10 +1000 Subject: [PATCH] Change logging and saved() function for Video/Photo --- app/Jobs/CatalogScan.php | 2 +- app/Models/Abstracted/Catalog.php | 16 ++++++++++++++++ app/Models/Photo.php | 15 --------------- app/Models/Video.php | 15 --------------- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/app/Jobs/CatalogScan.php b/app/Jobs/CatalogScan.php index 60391c0..e77bc79 100644 --- a/app/Jobs/CatalogScan.php +++ b/app/Jobs/CatalogScan.php @@ -51,7 +51,7 @@ class CatalogScan implements ShouldQueue, ShouldBeUnique */ public function handle() { - Log::info(sprintf('%s: Scanning [%s|%s]',__METHOD__,$this->o->objecttype(),$this->o->id)); + Log::info(sprintf('Scanning [%s] (%d)',$this->o->file_name(FALSE),$this->o->id)); if (! $this->o->isReadable()) { Log::alert(sprintf('Ignoring [%s], it is not readable',$this->o->file_name(FALSE))); diff --git a/app/Models/Abstracted/Catalog.php b/app/Models/Abstracted/Catalog.php index 8d87da5..63e5b44 100644 --- a/app/Models/Abstracted/Catalog.php +++ b/app/Models/Abstracted/Catalog.php @@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Storage; use App\Casts\PostgresBytea; +use App\Jobs\CatalogMove; use App\Models\{Make,Person,Software,Tag}; abstract class Catalog extends Model @@ -30,6 +31,21 @@ abstract class Catalog extends Model /* STATIC */ + public static function boot() + { + parent::boot(); + + // Any video saved, queue it to be moved. + self::saved(function($item) { + if ($item->scanned && (! $item->duplicate) && (! $item->remove) && ($item->shouldMove() === TRUE)) { + Log::info(sprintf('Need to Move [%s] to [%s]',$item->file_name_rel(),$item->file_name_rel(FALSE))); + + CatalogMove::dispatch($item) + ->onQueue('move'); + } + }); + } + /** * Return the prefix for the file path - dependant on the object * diff --git a/app/Models/Photo.php b/app/Models/Photo.php index 22659c1..f31ee38 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -41,21 +41,6 @@ class Photo extends Abstracted\Catalog 8 => -90, ]; - public static function boot() - { - parent::boot(); - - // Any photo saved, queue it to be moved. - self::saved(function($item) { - if ($item->scanned && (! $item->duplicate) && (! $item->remove) && ($x=$item->shouldMove()) === TRUE) { - Log::info(sprintf('%s: Need to Move [%s]','Photo',$item->id.'|'.serialize($x))); - - CatalogMove::dispatch($item) - ->onQueue('move'); - } - }); - } - /** * Calculate the GPS coordinates */ diff --git a/app/Models/Video.php b/app/Models/Video.php index 14f0b69..2828d3a 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -25,21 +25,6 @@ class Video extends Abstracted\Catalog 'software', ]; - public static function boot() - { - parent::boot(); - - // Any video saved, queue it to be moved. - self::saved(function($item) { - if ($item->scanned && (! $item->duplicate) && (! $item->remove) && ($x=$item->shouldMove()) === TRUE) { - Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$item->id.'|'.serialize($x))); - - CatalogMove::dispatch($item) - ->onQueue('move'); - } - }); - } - public function __get($key): mixed { if ($key === 'o') {