Change logging and saved() function for Video/Photo

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

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
*