diff --git a/app/Console/Commands/CatalogAutoDelete.php b/app/Console/Commands/CatalogAutoDelete.php index 53dc6f2..3ebe49b 100644 --- a/app/Console/Commands/CatalogAutoDelete.php +++ b/app/Console/Commands/CatalogAutoDelete.php @@ -49,14 +49,13 @@ class CatalogAutoDelete extends Command $class = $this->getModelType($this->argument('type')); $class::where('remove',1)->each(function($o) { - foreach ($o->myduplicates() as $oo) { + foreach ($o->myduplicates()->get() as $oo) { if (! $oo->signature OR ! $oo->file_signature) continue; if ($oo->signature == $o->signature AND $oo->file_signature == $o->file_signature) { $this->info(sprintf('Removing: %s (%s)',$o->id,$o->filename)); - continue; // Dispatch Job to move file. switch (strtolower($this->argument('type'))) { case 'photo': diff --git a/app/Models/Abstracted/Catalog.php b/app/Models/Abstracted/Catalog.php index cd9151c..3dd62ac 100644 --- a/app/Models/Abstracted/Catalog.php +++ b/app/Models/Abstracted/Catalog.php @@ -13,7 +13,7 @@ use App\Models\{Person,Software,Tag}; abstract class Catalog extends Model { protected static $includeSubSecTime = FALSE; - protected $dates = ['created']; + protected $dates = ['created','created_manual']; protected $casts = [ 'subsectime' => 'int', @@ -256,7 +256,7 @@ abstract class Catalog extends Model $file = $this->filename; if ($new) - $file = $this->file_name(FALSE); + $file = $this->file_name(TRUE); return (($short OR preg_match('/^\//',$file)) ? '' : config($this->type.'.dir').DIRECTORY_SEPARATOR).$file; } diff --git a/app/Models/Video.php b/app/Models/Video.php index 23a8e36..78e3f17 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -8,7 +8,6 @@ class Video extends Abstracted\Catalog { // ID3 Object private $_o = NULL; - protected $dates = ['created','created_manual']; public function getIDLinkAttribute() { diff --git a/app/Traits/Multimedia.php b/app/Traits/Multimedia.php index 74d6cb3..6c191ea 100644 --- a/app/Traits/Multimedia.php +++ b/app/Traits/Multimedia.php @@ -2,11 +2,11 @@ namespace App\Traits; -use App\Jobs\PhotoDelete; -use App\Models\Photo; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; +use App\Jobs\{PhotoDelete,VideoDelete}; + /** * Multimedia Controller Functions * @@ -65,6 +65,21 @@ trait Multimedia if ($delete AND $o->remove AND ($request->input('remove.'.$id) ? 1 : NULL)) { Log::info(sprintf('Dispatching delete for [%s]',$o->id)); + switch ($class) { + case 'photo': + $this->dispatch((new PhotoDelete($o))->onQueue('delete')); + Log::info(sprintf('Dispatching delete for [%s]',$o->id)); + break; + + case 'video': + $this->dispatch((new VideoDelete($o))->onQueue('delete')); + Log::info(sprintf('Dispatching delete for [%s]',$o->id)); + break; + + default: + Log::info(sprintf('Ignoring delete for [%s] - not configured.',$o->id)); + } + } else { $o->remove = $request->input('remove.'.$id) ? 1 : NULL; }