fix(archive): an upload leaves photos copied in by hand to the next scan

An upload batch that found the folder out of step resynced the sequence
from its sidecar and recorded the photo directory's current stamp. When
the photo directory had changed since the last scan (a photo copied into
originals/ by hand or by another process), that stamp hid the change from
every incremental scan, so only a full scan or the orphans check indexed
the photo.

The batch now asks ArchiveIndexer.PhotosChangedAsync under the lease
before it files its photos. When the photo directory had changed, the
resync records the photo stamp the index held before (none when none was
recorded), so the next incremental scan still reconciles the folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 22:07:58 +00:00
1 parent 49f56bb689
commit bf93434bec
3 files changed
+66 -11

No files matched your search

@@ -206,6 +206,29 @@ public abstract class PartialRowWriterTests(TestContext context) : DatabaseTest(
Assert.Empty((await fx.ScanAsync()).Sequences);
}
[Test]
public async Task AnUploadAfterAPhotoWasCopiedInByHandLeavesItToTheNextScan()
{
var fx = await FixtureAsync();
var sequence = await IndexedAsync(fx);
// Copied into the folder by hand, over a share: only a scan that reconciles the folder with its photos indexes it.
var folder = fx.Paths.Sequence("a");
await File.WriteAllBytesAsync(folder.File("IMG_0009.JPG"), Photos.Jpeg(Start.AddMinutes(2), 91), fx.Ct);
// A photo uploaded before this index's next scan is indexed with the sidecar's frames.
var staged = fx.Stage(Start.AddMinutes(1), seed: 90);
await fx.Service.Ingest.CommitAsync(new IngestRequest(fx.Archive.Id, sequence.Id, null, null, staged.Path, "IMG_0004.JPG", staged.Size, staged.Sha256, null, null),
fx.Ct);
Assert.Equal(4, (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!.FrameCount);
// The upload left the folder changed, so the next incremental scan reconciles it and indexes the copied photo.
Assert.SequenceEqual([sequence.Id], (await fx.ScanAsync()).Sequences);
var frames = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct);
Assert.Count(5, frames);
Assert.Contains("IMG_0009.JPG", frames.Select(f => f.FileName));
Assert.Empty((await fx.ScanAsync()).Sequences);
}
[Test]
public async Task AnInfoEditKeepsTheSettingsTheApiSavedAfterItReadTheSequence()
{