fix(copies): close the tenth verification round of owner review 6

- A merge verify that finds a hashed photo the plan did not copy (held by
  a third sequence when planned) held by nothing now drops its journal and
  fails as a stale plan, so the retry plans again and lists the photo as a
  last copy instead of failing with "did not match after copying" forever.
- A comparison settles no details of a pair being integrated, and the
  Integrate's Details stage refuses a line decided as the server's whose
  server value is now this PC's own, so a background push or pull no longer
  reverses the user's line-by-line choice (owner Q4).
- A 404 for a server sequence no local copy is linked to deletes only its
  Candidate pairs; a Kept apart answer counts the hit as a linked pair does
  (two 404s GoneRecheck apart), so a moment's 404 neither re-asks nor
  auto-links a pair the user kept separate (owner Q1). Upload all local
  sends the local sequence once the deletion is confirmed.
- Download originals into a local copy the server key names and that is
  paired with the server sequence links it first and fills it as a linked
  copy: its tombstones hold and its details are compared, not overwritten.
- An upload of a sequence with a Candidate pair goes under a key of the
  job, and one that joins a server sequence this PC already knows compares
  its details instead of sending them all over the server's.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 13:17:23 +01:00
1 parent c1c02d8ef7
commit e002c583d6
12 files changed
+383 -34

No files matched your search

@@ -203,6 +203,34 @@ public sealed class SyncServiceCopyTests(TestContext context)
Assert.Equal(local.Id, upload.Single().Local!.Id);
}
[Test]
public async Task AKeptApartServerSequenceAnswering404OnceKeepsTheAnswerAndIsNeverLinkedByItself()
{
await using var f = await SyncFixture.CreateAsync(context);
var nas = new FakeSyncRemote { Server = HomeFolders.IdKey(Guid.NewGuid()) };
var photos = f.NewPhotos(3);
var local = await f.LocalAsync("Comet", photos);
var remote = nas.Add("2026-09-28 Canon", photos);
remote.FirstCapture = local.FirstCapture;
remote.CameraModel = local.CameraModel;
await f.Sync.RefreshAsync(nas, new SyncPolicy(), f.Ct);
var pair = (await f.Sync.Copies.ListByServerAsync(nas.Server, f.Ct)).Single();
Assert.True(await f.Sync.Copies.SetStateAsync(pair.Id, CopyState.Candidate, CopyState.KeptApart,
new CopyAnswer(pair.Fingerprint, pair.Score.Shared, null, false, DateTimeOffset.UtcNow), f.Ct));
// Moved to the server's trash and restored: one refresh gets a 404, the next lists it again.
nas.Sequences.Remove(remote.Id);
await f.Sync.RefreshAsync(nas, new SyncPolicy(), f.Ct);
Assert.Equal((CopyState.KeptApart, 1), ((await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!.State, (await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!.RemoteGoneHits));
nas.Sequences[remote.Id] = remote;
await f.Sync.RefreshAsync(nas, new SyncPolicy { Linking = CopyLinking.WhenIdentical }, f.Ct);
// Keep separate is remembered (owner Q1): not asked again, and not linked although the photos are identical.
var after = (await f.Sync.Copies.ListByServerAsync(nas.Server, f.Ct)).Single();
Assert.Equal((pair.Id, CopyState.KeptApart, 0), (after.Id, after.State, after.RemoteGoneHits));
Assert.Null(await f.Sync.LinkOfAsync(nas.Server, local.Id, f.Ct));
}
[Test]
public async Task ASequenceReadAsDeletedOnTheServerIsClearedWhenItIsListedAgainOrLinkedAgain()
{