fix(archive): scans see frames another writer changed; partial writers keep the row and the lease
A desktop sharing the archive that imports into an existing sequence lists the new frames in the sidecar itself and keeps its ThumbsBuilt and ProxiesBuilt. The server scan cleared the flags only when SequenceAdopter.Reconcile found unindexed photos, so it queued no image pass: the new frames, and every frame they renumbered, answered 404 on /thumb and /proxy until a pass was forced. A scan now also clears AnalyzedLight, ThumbsBuilt and ProxiesBuilt when the sidecar's frames version differs from the index row's, decided under the sequence lease, and its follow-ups queue the light analysis and both passes. Writers that change only part of a sequence wrote the whole index row back from a sidecar read under a lease they had already released (decode tiers) or without any (verify stamp): an ingest or a PATCH committed in between was undone, and a row written from a sidecar the index had not synced claimed its frames version, hiding the change from the scan. FrameTiers.RecordAsync and ArchiveVerifier now write the sidecar and only their own columns (SequenceRepository.RecordTiersAsync, RecordVerifiedAsync) under one lease. They and the image passes record the folder's scan stamps only while the index holds the sidecar's frames version (ArchiveIndexer.RecordStampsInStepAsync), so the next scan still sees frames another process added. An image pass decided ThumbsBuilt/ProxiesBuilt from the sidecar it read at its start and set the flag again after a scan had cleared it for photos added meanwhile, so no pass was queued for them. MarkAsync now holds the lease for the sidecar and the index, and sets the flag only while the sidecar lists the photos the pass read at the same indexes; otherwise it clears it. A rebuild deleted every row whose folder was not among those listed when it began, so a sequence that got its first frame or was created by an upload session while it ran lost its row (404 for the Uploader, a second '(2)' sequence for the session). A row is now checked again under its lease, as it and its folder are then, before it goes. Tests: a desktop's ArchiveIngest commit followed by a server scan (Data and Server, /thumb and /proxy answer 200 for every frame); a thumbnail pass with a scan's reconcile in between; tier records and a verify stamp interleaved with a PATCH and with another writer's frames, on SQLite and PostgreSQL; a rebuild during which uploads place and create sequences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
11 files changed
+550
-75
No files matched your search
@@ -195,6 +195,24 @@ public sealed class SequenceRepository
|
||||
await _db.ExecuteAsync("UPDATE sequences SET status = (status | $2) & ~$3, updated_at = $4 WHERE id = $1",
|
||||
[id, (int)set, (int)clear, DateTimeOffset.UtcNow], cancellationToken).ConfigureAwait(false) > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Records decode tiers written to the sequence's frames (<see cref="FrameRepository.UpdateTiersAsync"/>): the status
|
||||
/// flags in <paramref name="set"/> and the preview-only count, in one statement. The frames, their versions and the
|
||||
/// settings stay as they are, so an ingest or a settings edit committed meanwhile is never written back over.
|
||||
/// </summary>
|
||||
public async Task<bool> RecordTiersAsync(Guid id, SequenceStatus set, int previewOnlyCount, CancellationToken cancellationToken = default) =>
|
||||
await _db.ExecuteAsync("UPDATE sequences SET status = status | $2, preview_only_count = $3, updated_at = $4 WHERE id = $1",
|
||||
[id, (int)set, previewOnlyCount, DateTimeOffset.UtcNow], cancellationToken).ConfigureAwait(false) > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Records a verify: status flags set and cleared and the verify time, in one statement; every other field stays as
|
||||
/// it is (<see cref="RecordTiersAsync"/>).
|
||||
/// </summary>
|
||||
public async Task<bool> RecordVerifiedAsync(Guid id, SequenceStatus set, SequenceStatus clear, DateTimeOffset verifiedAt,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
await _db.ExecuteAsync("UPDATE sequences SET status = (status | $2) & ~$3, verified_at = $4, updated_at = $5 WHERE id = $1",
|
||||
[id, (int)set, (int)clear, verifiedAt, DateTimeOffset.UtcNow], cancellationToken).ConfigureAwait(false) > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Records an analysis: status flags set and cleared, the warning count and, for a deep analysis, the compact
|
||||
/// summary (<paramref name="analysisJson"/> null keeps the stored one).
|
||||
|
||||
Reference in new issue
Block a user