Change logging and saved() function for Video/Photo

This commit is contained in:
Deon George 2024-09-18 11:50:10 +10:00
parent 59925f3af9
commit f136360e5c
4 changed files with 17 additions and 31 deletions

View File

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

View File

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

View File

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

View File

@ -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') {