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:
1 parent
c1c02d8ef7
commit
e002c583d6
12 files changed
+383
-34
No files matched your search
@@ -800,6 +800,73 @@ public sealed class IntegrateTests(TestContext context)
|
||||
Assert.Equal("Comet (night)", remote.Title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A linked pair whose details were agreed, then edited on this PC (Window41, not sent yet), with every detail line
|
||||
/// decided as the server's (Window33): the plan of an Integrate the user confirmed.
|
||||
/// </summary>
|
||||
private static async Task<(Sequence Local, FakeSequence Remote, FoundCopy Pair, IntegratePlan Plan)> EditedHereServerChosenAsync(SyncFixture f)
|
||||
{
|
||||
var photos = f.NewPhotos(3);
|
||||
var local = await f.LocalAsync("Comet", photos.Take(2).ToList(), SyncFixture.Window33);
|
||||
var remote = f.Remote.Add("Comet", [photos[0], photos[2]], SyncFixture.Window33);
|
||||
await f.Sync.LinkAsync(f.Server, remote.Id, local.Id, f.Ct);
|
||||
await f.Sync.RefreshSequencesAsync(f.Remote, [remote.Id], new SyncPolicy(AutoSyncSettings: false), f.Ct);
|
||||
Assert.Equal(local.SettingsVersion, (await f.Sync.Links.GetAsync(f.Server, remote.Id, f.Ct))!.BaseLocalSettings);
|
||||
local = await f.EditLocalSettingsAsync(local.Id, SyncFixture.Window41);
|
||||
var pair = (await f.Sync.Copies.FindRemoteAsync(local.Id, f.Server, remote.Id, f.Ct))!;
|
||||
var choices = await ChoicesAsync(f, local.Id, remote.Id, CopyPhotoPolicy.Union);
|
||||
Assert.NotEmpty(choices.Details);
|
||||
choices = choices with { Details = choices.Details.ToDictionary(d => d.Key, _ => CopySide.Other) };
|
||||
var plan = await Planner(f).PlanAsync(f.Remote, pair, choices, PlanContext(), f.Ct);
|
||||
return (local, remote, pair, plan);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ABackgroundSyncDuringTheIntegrateLeavesTheDetailsToTheUsersChoice()
|
||||
{
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (engine, handler) = Engine(f);
|
||||
await using var _ = engine;
|
||||
await engine.StartAsync(f.Ct);
|
||||
var (local, remote, _, plan) = await EditedHereServerChosenAsync(f);
|
||||
// The server fires sequenceChanged as the photos land (or the periodic refresh runs): the agent compares the pair.
|
||||
handler.BeforeStage = async stage =>
|
||||
{
|
||||
if (stage == IntegrateStage.Details) await f.Sync.RefreshSequencesAsync(f.Remote, [remote.Id], new SyncPolicy(), f.Ct);
|
||||
};
|
||||
|
||||
var job = await CopyJobs.EnqueueIntegrateAsync(engine, f.Sync.Copies, plan, local.DisplayTitle, f.Ct);
|
||||
await f.Archive.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
// The server's settings the user kept are on both sides: this PC's edit was not pushed over them meanwhile.
|
||||
Assert.True(SyncRules.SameSettings(SyncFixture.Window33, remote.SettingsJson), remote.SettingsJson);
|
||||
Assert.True(SyncRules.SameSettings(SyncFixture.Window33, (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.SettingsJson));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AServerValueThatIsThisPcsOwnOverALineDecidedAsTheServersStopsTheDetails()
|
||||
{
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (engine, handler) = Engine(f);
|
||||
await using var _ = engine;
|
||||
await engine.StartAsync(f.Ct);
|
||||
var (local, remote, pair, plan) = await EditedHereServerChosenAsync(f);
|
||||
// This PC's planned value reaches the server while the photos travel (a push the job did not make).
|
||||
handler.BeforeStage = stage =>
|
||||
{
|
||||
if (stage == IntegrateStage.Photos) f.Remote.EditSettings(remote.Id, SyncFixture.Window41);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
var job = await CopyJobs.EnqueueIntegrateAsync(engine, f.Sync.Copies, plan, local.DisplayTitle, f.Ct);
|
||||
var failed = await f.Archive.WaitForAsync(job.Id, JobState.Failed);
|
||||
|
||||
// Not absorbed as a newer edit, which would reverse the user's choice on both sides: the details stop, the photos stay.
|
||||
Assert.Equal(Loc.L("Errors.Copies.DetailsChanged"), failed.Error);
|
||||
Assert.Equal(CopyState.Linked, (await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!.State);
|
||||
Assert.Equal(3, RemoteHashes(remote).Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ACancelledQueuedJobSetsThePairBack()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user