More changes to scanall to address memory issues

This commit is contained in:
2024-09-18 11:36:42 +10:00
parent a6796a24ae
commit 59925f3af9
2 changed files with 44 additions and 28 deletions

View File

@@ -46,6 +46,10 @@ class CatalogScanAll extends Command
$started = Carbon::now();
$class = $this->getModelType($this->argument('type'));
// Flag everything if we are forcing a rescan
if ($this->option('scan'))
$class::select('id')->update(['flag'=>TRUE]);
Log::info('Scanning disk: '.Storage::disk('nas')->path(''));
$c = 0;
@@ -73,38 +77,21 @@ class CatalogScanAll extends Command
}
foreach ($list as $o) {
// Check the details are valid
if ($o->file_signature === $o->getObjectOriginal('file_signature')) {
// For sanity, we'll check a couple of other attrs
if (($o->width !== $o->getObjectOriginal('width')) || ($o->height !== $o->getObjectOriginal('height'))) {
Log::alert(sprintf('Dimensions [%s] (%s x %s) mismatch for [%s]',
$o->dimensions,
$o->getObjectOriginal('width'),
$o->getObjectOriginal('height'),
$o->file_name(FALSE)));
if ($o->flag) {
$o->scanned = FALSE;
$o->flag = FALSE;
$o->touch();
$c++;
continue;
if ($this->option('scan')) {
Log::info(sprintf('Forcing re-scan of [%s] - queued',$o->filename));
CatalogScan::dispatch($o)
->onQueue('scan');
}
} else {
Log::alert(sprintf('File Signature [%s] doesnt match [%s] for [%s]',
$o->getObjectOriginal('file_signature'),
$o->file_signature,
$o->file_name(FALSE)));
$c++;
continue;
}
$o->scanned = FALSE;
$o->touch();
if ($this->option('scan')) {
Log::info(sprintf('Forcing re-scan of [%s] - queued',$o->filename));
CatalogScan::dispatch($o)
->onQueue('scan');
$o->flag = FALSE;
$o->touch();
}
$c++;