fix: keychain view

This commit is contained in:
hashbro
2026-09-21 01:44:03 +08:00
parent 7651f6a589
commit 92d9dde5cb
3 changed files with 96 additions and 34 deletions
+16 -9
View File
@@ -40,6 +40,13 @@ class DsResultStore
return ['stored' => false, 'reason' => 'video_skipped', 'filename' => $filename];
}
// Images are only persisted when album storage is enabled. When it's
// off, drop them entirely — no ds-results file, no .seen marker, no
// photos table row — so the device's disk footprint stays minimal.
if ($this->isImage($filename) && ! $device->albumStorageEnabled()) {
return ['stored' => false, 'reason' => 'image_skipped_album_off', 'filename' => $filename];
}
$raw = $payload['data'] ?? null;
if (! is_string($raw) || $raw === '') {
return ['stored' => false, 'reason' => 'no_data', 'filename' => $filename];
@@ -151,11 +158,15 @@ class DsResultStore
return $seen;
}
// 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
// Images reach here only when album storage is enabled (store() drops
// images entirely when album is off). 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 (the
// device record was recreated, an exception was swallowed, …) and
// would otherwise block the photo from ever entering the album.
// would otherwise block the photo from ever entering the album. When
// a Photo row exists we treat it as a duplicate; otherwise we retry
// the ingest by returning false so store() re-stores + calls
// ingestPhotos.
$hasPhoto = Photo::query()
->where('device_id', $device->id)
->where('sha256', $hash)
@@ -168,11 +179,7 @@ class DsResultStore
return true;
}
// 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();
return false;
}
private function markSeen(Device $device, string $hash, string $filename): void