feat: 18
This commit is contained in:
@@ -98,17 +98,36 @@ class DsResultStore
|
||||
|
||||
private function alreadyIngested(Device $device, string $filename, string $hash): bool
|
||||
{
|
||||
if (Storage::disk('local')->exists($this->seenPath($device, $hash))) {
|
||||
return true;
|
||||
$isImage = $this->isImage($filename);
|
||||
$seen = Storage::disk('local')->exists($this->seenPath($device, $hash));
|
||||
|
||||
if (! $isImage) {
|
||||
// Non-images (wallet dumps, memo dbs, …): .seen is the only dedup.
|
||||
return $seen;
|
||||
}
|
||||
if ($this->isImage($filename)
|
||||
&& Photo::query()->where('device_id', $device->id)->where('sha256', $hash)->exists()) {
|
||||
$this->markSeen($device, $hash, $filename);
|
||||
|
||||
// For images, the Photo table is the source of truth for album dedup.
|
||||
// markSeen() runs before ingestPhotos(), so a bare .seen marker can
|
||||
// survive a failed/skipped album ingest (album storage was off, the
|
||||
// device record was recreated, an exception was swallowed, …) and
|
||||
// would otherwise block the photo from ever entering the album.
|
||||
$hasPhoto = Photo::query()
|
||||
->where('device_id', $device->id)
|
||||
->where('sha256', $hash)
|
||||
->exists();
|
||||
if ($hasPhoto) {
|
||||
if (! $seen) {
|
||||
$this->markSeen($device, $hash, $filename);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
// No Photo row yet. When album storage is enabled, retry the ingest
|
||||
// (return false so store() re-stores + calls ingestPhotos). When
|
||||
// disabled, fall back to .seen for raw-file dedup so we don't keep
|
||||
// re-storing identical bytes under every new command_id.
|
||||
return $seen && ! $device->albumStorageEnabled();
|
||||
}
|
||||
|
||||
private function markSeen(Device $device, string $hash, string $filename): void
|
||||
|
||||
Reference in New Issue
Block a user