Photo scan and move implemented, and remove redundant files
This commit is contained in:
@@ -3,27 +3,29 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
use App\Jobs\{PhotoMove,VideoMove};
|
||||
use App\Jobs\CatalogMove as Job;
|
||||
use App\Traits\Type;
|
||||
|
||||
class CatalogMove extends Command
|
||||
{
|
||||
use DispatchesJobs;
|
||||
use Type;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'catalog:move {type : Photo | Video }';
|
||||
protected $signature = 'catalog:move'
|
||||
.' {type : Photo | Video }'
|
||||
.' {id : Photo ID}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Trigger Moves';
|
||||
protected $description = 'Move Photo/Video based on their meta data';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -32,35 +34,10 @@ class CatalogMove extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$class = 'App\Models\\'.$this->argument('type');
|
||||
$class = $this->getModelType($this->argument('type'));
|
||||
|
||||
if (! class_exists($class))
|
||||
abort(500,sprintf('No class [%s]',$this->argument('type')));
|
||||
$o = $class::findOrFail($this->argument('id'));
|
||||
|
||||
foreach ($class::where('filename','LIKE','%INCOMING%')->get() as $o) {
|
||||
// Catch any files that are already there.
|
||||
if ($o->moveable() === 1) {
|
||||
$o->duplicate = TRUE;
|
||||
$o->save();
|
||||
continue;
|
||||
}
|
||||
|
||||
$x = NULL;
|
||||
if (! $o->scanned OR $o->duplicate OR $o->remove OR ($x=$o->moveable()) !== TRUE) {
|
||||
$this->warn(sprintf('Ignoring (%s)[%s]... [%s]',$o->id,$o->file_path(),$x));
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (strtolower($this->argument('type'))) {
|
||||
case 'photo':
|
||||
$this->dispatch((new PhotoMove($o))->onQueue('move'));
|
||||
break;
|
||||
case 'video':
|
||||
$this->dispatch((new VideoMove($o))->onQueue('move'));
|
||||
break;
|
||||
default:
|
||||
$this->error('Dont know how to handle: ',$this->argument('type'));
|
||||
}
|
||||
}
|
||||
return Job::dispatchSync($o);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user