Be more liberal with finding duplicates

This commit is contained in:
Deon George 2024-10-05 21:10:15 +10:00
parent 2b4eadc33b
commit b3f381b743

View File

@ -120,36 +120,34 @@ abstract class Catalog extends Model
$query->where(fn($q)=>$q->whereNull('ignore_duplicate')
->orWhere('ignore_duplicate',FALSE));
// Exclude those marked as remove
$query->where(fn($q)=>$q->where('remove','<>',TRUE));
$query
->where(function($q) {
$q->when($this->attributes['signature'],
fn($q)=>$q->where('signature','=',$this->attributes['signature']))
->orWhere('file_signature','=',$this->attributes['file_signature']); })
$query->where(function($q) {
$q->when($this->attributes['signature'],fn($q)=>$q->where('signature','=',$this->attributes['signature']))
->orWhere('file_signature','=',$this->attributes['file_signature'])
// Where the signature is the same
->orWhere(function($q) {
// Or they have the same time taken with the same camera
if ($this->attributes['created'] && $this->software_id) {
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created'])
->orWhere('created_manual','=',$this->attributes['created']));
// Where the signature is the same
->orWhere(function($q) {
// Or they have the same time taken with the same camera
if ($this->attributes['created'] && $this->software_id) {
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created'])
->orWhere('created_manual','=',$this->attributes['created']));
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
$q->where('software_id','=',$this->attributes['software_id']);
$q->where('software_id','=',$this->attributes['software_id']);
} elseif ($this->attributes['created_manual'] && $this->software_id) {
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created_manual'])
->orWhere('created_manual','=',$this->attributes['created_manual']));
} elseif ($this->attributes['created_manual'] && $this->software_id) {
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created_manual'])
->orWhere('created_manual','=',$this->attributes['created_manual']));
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
$q->where('software_id','=',$this->attributes['software_id']);
}
});
});
$q->where('software_id','=',$this->attributes['software_id']);
}
});
return $query;
}
@ -413,7 +411,7 @@ abstract class Catalog extends Model
// Test if the target dir is writable
// @todo The target dir may not exist yet, so we should check that a parent exists and is writable.
$this->move_reason = 'Target parent dir doesnt is not writable';
$this->move_reason = 'Target parent dir is not writable';
if (! $this->isParentWritable(dirname($this->file_name_rel(FALSE))))
return FALSE;