fix(copies): close the eighth verification round of owner review 6
- A merge's Renders stage never deletes what sits at a journaled render target: a file or folder it did not copy there (a render of the kept sequence made after a failed run), or a path another render of the kept sequence names, makes the copy take a new free name instead. - A merge's Verify stage records the hash it read for each kept frame the index had none for, the Details stage leaves the versions the verify filed out of Main, and Two versions also lists a whole-second instant holding two frames of one size and other content (owner Q3). - The Integrate journal keeps the losers the plan listed as last copies; a loser that became the only copy while the job ran is never trashed: the journal goes and the job fails as a stale plan. - Download originals of a server sequence whose earlier download was unlinked or kept apart makes a new local sequence under a key of the job, instead of filling the old one, re-linking it and overwriting its details. - An upload never links again from its checkpoint a server sequence the user kept apart since the attempt that made it. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
123ceba845
commit
aad8ae46dd
11 files changed
+536
-36
No files matched your search
@@ -527,6 +527,43 @@ public sealed class IntegrateTests(TestContext context)
|
||||
Assert.Equal(CopyState.Linked, (await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!.State);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ALoserWhoseOtherHolderGoesBeforeTheTrashIsNeverTrashedUnlisted()
|
||||
{
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (engine, handler) = Engine(f);
|
||||
await using var _ = engine;
|
||||
await engine.StartAsync(f.Ct);
|
||||
|
||||
// This PC's losing version (the server wins) and the server's (this PC wins), each held by a third local sequence
|
||||
// when planned: neither is a last copy. That sequence's copy is flagged corrupt while the photos move.
|
||||
foreach (var (n, policy, loser) in new[] { (1, CopyPhotoPolicy.OtherWins, 104), (2, CopyPhotoPolicy.ThisPcWins, 205) })
|
||||
{
|
||||
var (local, remote, pair) = await ScenarioAsync(f, n);
|
||||
var third = await LocalAsync(f, $"Third {n}", [(loser, 30_250, "IMG_0004.JPG")]);
|
||||
var plan = await Planner(f).PlanAsync(f.Remote, pair, await ChoicesAsync(f, local.Id, remote.Id, policy), PlanContext(), f.Ct);
|
||||
Assert.True(plan.Destructive, policy.ToString());
|
||||
Assert.Empty(plan.LastCopies);
|
||||
handler.BeforeStage = async stage =>
|
||||
{
|
||||
if (stage != IntegrateStage.Trash) return;
|
||||
var held = (await f.Db.Frames.ListBySequenceAsync(third.Id, cancellationToken: f.Ct)).Single();
|
||||
await f.Db.Frames.UpdateFlagsAsync([held.Id], FrameFlags.Corrupt, FrameFlags.None, f.Ct);
|
||||
};
|
||||
var job = await CopyJobs.EnqueueIntegrateAsync(engine, f.Sync.Copies, plan, local.DisplayTitle, f.Ct);
|
||||
var failed = await f.Archive.WaitForAsync(job.Id, JobState.Failed);
|
||||
|
||||
// Its only copy now: it stays where it was (nothing in either trash), and the journal goes so a retry plans again.
|
||||
Assert.Equal(Loc.L("Errors.Copies.StalePlan"), failed.Error);
|
||||
if (policy == CopyPhotoPolicy.OtherWins) Assert.Contains(Sha(loser, 30_250), await LocalHashesAsync(f, local.Id));
|
||||
else Assert.Contains(Sha(loser, 30_250), RemoteHashes(remote));
|
||||
Assert.Empty(f.Remote.Trashed);
|
||||
Assert.False(File.Exists(IntegrateJournal.PathFor(f.Archive.Paths, job.Id)));
|
||||
handler.BeforeStage = null;
|
||||
await WaitIdleAsync(f, local.Id);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheServersLoserGoesToItsTrashAtTheVersionItsDryRunRead()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user