Updated ScanAll to enable scanning all photos
This commit is contained in:
parent
83d6d1e055
commit
bd5fb5d46f
@ -39,7 +39,7 @@ class CatalogScan extends Command
|
|||||||
|
|
||||||
if (! is_readable($o->file_path())) {
|
if (! is_readable($o->file_path())) {
|
||||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||||
exit;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$o->setDateCreated();
|
$o->setDateCreated();
|
||||||
|
@ -4,55 +4,59 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use App\Model\Photo;
|
|
||||||
|
use App\Models\Photo;
|
||||||
use App\Jobs\CatalogScan;
|
use App\Jobs\CatalogScan;
|
||||||
|
|
||||||
class PhotoScanAll extends Command
|
class PhotoScanAll extends Command
|
||||||
{
|
{
|
||||||
use DispatchesJobs;
|
use DispatchesJobs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'photo:scanall';
|
protected $signature = 'photo:scanall '.
|
||||||
|
'{--scanned : Rescan Scanned Photos}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Command description';
|
protected $description = 'Rescan Photos';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
Photo::NotScanned()->chunk(200,function ($data) {
|
$o = ($this->option('scanned') ? Photo::NotRemove() : Photo::NotScanned());
|
||||||
foreach ($data as $o)
|
|
||||||
{
|
$o->each(function ($item) {
|
||||||
if ($o->remove) {
|
if ($item->remove) {
|
||||||
Log::warning(sprintf('Not scanning [%s], marked for removal',$o->id));
|
Log::warning(sprintf('Not scanning [%s], marked for removal',$item->id));
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dispatch((new CatalogScan($o))->onQueue('scan'));
|
Log::info(sprintf('%s: Rescanning [%s]',__METHOD__,$item->id));
|
||||||
}
|
$this->dispatch((new CatalogScan($item))->onQueue('scan'));
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
Log::info(sprintf('Processed [%s]',$o->count()));
|
||||||
|
}
|
||||||
|
}
|
@ -192,6 +192,7 @@ class Photo extends Abstracted\Catalog
|
|||||||
$this->thumbnail = exif_thumbnail($this->file_path());
|
$this->thumbnail = exif_thumbnail($this->file_path());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// @todo Couldnt get the thumbnail, so we should create one.
|
// @todo Couldnt get the thumbnail, so we should create one.
|
||||||
|
Log::info(sprintf('Unable to create thumbnail for %s (%s)',$this->id,$e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user