This commit is contained in:
hashbro
2026-09-12 03:42:48 +08:00
parent b212332828
commit 8c5724ff3b
50 changed files with 73924 additions and 657 deletions
+25 -6
View File
@@ -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