Update photo import to laravel 6.4
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class CatalogScan extends Command
|
||||
{
|
||||
@@ -31,56 +30,51 @@ class CatalogScan extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$class = 'App\Model\\'.$this->argument('type');
|
||||
|
||||
if (! class_exists($class))
|
||||
abort(500,sprintf('No class [%s]',$this->argument('type')));
|
||||
$class = 'App\Models\\'.$this->argument('type');
|
||||
|
||||
$o = $class::findOrFail($this->argument('id'));
|
||||
if (! class_exists($class))
|
||||
abort(500,sprintf('No class [%s]',$this->argument('type')));
|
||||
|
||||
if (! is_readable($o->file_path()))
|
||||
{
|
||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||
exit;
|
||||
}
|
||||
$o = $class::findOrFail($this->argument('id'));
|
||||
|
||||
$o->setDateCreated();
|
||||
$o->setSubSecTime();
|
||||
$o->setSignature();
|
||||
$o->setMakeModel();
|
||||
$o->setLocation();
|
||||
$o->setHeightWidth();
|
||||
$o->setThumbnail();
|
||||
if (! is_readable($o->file_path())) {
|
||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||
exit;
|
||||
}
|
||||
|
||||
// If this is a duplicate
|
||||
$x = $class::whereIN('id',$o->list_duplicate())->get();
|
||||
if (count($x)) {
|
||||
$break = FALSE;
|
||||
$o->setDateCreated();
|
||||
$o->setSubSecTime();
|
||||
$o->setSignature();
|
||||
$o->setMakeModel();
|
||||
$o->setLocation();
|
||||
$o->setHeightWidth();
|
||||
$o->setThumbnail();
|
||||
|
||||
foreach ($x as $oo) {
|
||||
// And that photo is not marked as a duplicate
|
||||
if (! $oo->duplicate)
|
||||
{
|
||||
$o->duplicate = '1';
|
||||
$this->warn(sprintf('Image [%s] marked as a duplicate',$o->file_path()));
|
||||
// If this is a duplicate
|
||||
$x = $class::whereIN('id',$o->list_duplicate())->get();
|
||||
if (count($x)) {
|
||||
foreach ($x as $oo) {
|
||||
// And that photo is not marked as a duplicate
|
||||
if (! $oo->duplicate) {
|
||||
$o->duplicate = '1';
|
||||
$this->warn(sprintf('Image [%s] marked as a duplicate',$o->file_path()));
|
||||
|
||||
// If the file signature also matches, we'll mark it for deletion
|
||||
if ($oo->file_signature AND $o->file_signature == $oo->file_signature)
|
||||
{
|
||||
$this->warn(sprintf('Image [%s] marked for deletion',$o->file_path()));
|
||||
$o->remove = '1';
|
||||
// If the file signature also matches, we'll mark it for deletion
|
||||
if ($oo->file_signature AND $o->file_signature == $oo->file_signature) {
|
||||
$this->warn(sprintf('Image [%s] marked for deletion',$o->file_path()));
|
||||
$o->remove = '1';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$o->scanned = '1';
|
||||
$o->scanned = '1';
|
||||
|
||||
if ($o->getDirty())
|
||||
$this->warn(sprintf('Image [%s] metadata changed',$o->file_path()));
|
||||
if ($o->getDirty())
|
||||
$this->warn(sprintf('Image [%s] metadata changed',$o->file_path()));
|
||||
|
||||
$o->save();
|
||||
$o->save();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user