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') $query->where(fn($q)=>$q->whereNull('ignore_duplicate')
->orWhere('ignore_duplicate',FALSE)); ->orWhere('ignore_duplicate',FALSE));
// Exclude those marked as remove $query
$query->where(fn($q)=>$q->where('remove','<>',TRUE)); ->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) { // Where the signature is the same
$q->when($this->attributes['signature'],fn($q)=>$q->where('signature','=',$this->attributes['signature'])) ->orWhere(function($q) {
->orWhere('file_signature','=',$this->attributes['file_signature']) // 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 if (static::$includeSubSecTime)
->orWhere(function($q) { $q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
// 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('software_id','=',$this->attributes['software_id']);
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
$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) { if (static::$includeSubSecTime)
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created_manual']) $q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
->orWhere('created_manual','=',$this->attributes['created_manual']));
if (static::$includeSubSecTime) $q->where('software_id','=',$this->attributes['software_id']);
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime')); }
});
$q->where('software_id','=',$this->attributes['software_id']);
}
});
});
return $query; return $query;
} }
@ -413,7 +411,7 @@ abstract class Catalog extends Model
// Test if the target dir is writable // 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. // @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)))) if (! $this->isParentWritable(dirname($this->file_name_rel(FALSE))))
return FALSE; return FALSE;