fix(copies): close the fourth verification round of owner review 6
The fourth verification round of the matches work found 18 defects in the merge, Integrate and Matches surfaces. This commit fixes them: - An Integrate job now carries the planning account's id, so its re-plan decides ownership the way the dialog did. - A merge skips only a project the kept sequence holds a real copy of (name, offset head and history content) and re-points its renders to that copy. - A merge runs its trash checks before the Links stage and records an undo, so an abandoned merge gives the other sequence back its link, session keys and pairs. - The metered hold adopts automatic transfers that were paused before a restart. - Apply in the Compare dialog re-plans when the plan is pending or stale. - The Library's Two versions... lists the second versions a Union merge leaves, each with Drop... (dry run, confirmation, verified partner). A merge job's Open shows that list. - The merge's typed confirmation is the invariant count, and the prompt names it in all 38 languages. - Italian text uses Principale and Gemello. The Main project is named through WorkspaceText in the Projects part and in the twin tooltip. - The session keys tooltip is split into two keys, and To trash... and Delete on server... say why they are disabled. - The capture restores the editor account before the Matches scenes. - Upload again follows SyncHost.CanSendSync (Upload with Edit). - Matches rows trim archive names in the middle on a rebalanced grid; the Projects part rows trim, with the full text in the tooltip. - The sample project targets use ProjectTransplant.FreeName. DECISIONS, CHANGELOG, STATUS 8.7, the request doc and the 16 changed capture baselines are updated. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3c99badcfe
commit
2c06e7ac2b
171 files changed
+1591
-218
No files matched your search
@@ -294,6 +294,32 @@ public sealed class CopyEngineTests(TestContext context)
|
||||
Assert.True((await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct)).Any(fr => fr.Sha256 == Sha(a)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DropOwnVersionTrashesOneVersionOfALocalSequenceAndIsRefusedOnceTheOtherIsGone()
|
||||
{
|
||||
// Two versions a Union merge left in one sequence, its pair gone (owner Q3): listed, and each can be dropped.
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (local, _, a, b) = await VersionsAsync(f);
|
||||
using var engine = Engine(f);
|
||||
var photo = (await engine.VersionsAsync(local.Id, f.Ct)).Single();
|
||||
var (frameA, frameB) = photo.FirstSha256 == Sha(a) ? (photo.FirstFrameId, photo.SecondFrameId) : (photo.SecondFrameId, photo.FirstFrameId);
|
||||
Assert.True(photo.CapturedAt is not null && photo.FirstSize > 0 && photo.SecondSize > 0);
|
||||
|
||||
var dropA = await engine.PlanDropOwnVersionAsync(local.Id, frameA, f.Ct);
|
||||
Assert.Equal((1, frameB, Sha(b)), (dropA.Plan.Frames.Count, dropA.PartnerFrameId, dropA.PartnerSha256));
|
||||
Assert.Equal(Sha(a), dropA.LastCopies.Single().Key);
|
||||
var dropB = await engine.PlanDropOwnVersionAsync(local.Id, frameB, f.Ct);
|
||||
|
||||
Assert.Equal(1, await engine.DropOwnVersionAsync(dropB, f.Ct));
|
||||
var left = await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct);
|
||||
Assert.True(left.Any(fr => fr.Sha256 == Sha(a)) && !left.Any(fr => fr.Sha256 == Sha(b)));
|
||||
Assert.Empty(await engine.VersionsAsync(local.Id, f.Ct));
|
||||
|
||||
// The other version is gone now: dropping this one too would lose the photo, so nothing moves.
|
||||
await Assert.ThrowsAsync<StaleCopyPlanException>(() => engine.DropOwnVersionAsync(dropA, f.Ct));
|
||||
Assert.True((await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct)).Any(fr => fr.Sha256 == Sha(a)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A pair holding one photo in two versions (a Union keep-both): two files of one sub-second capture time, on both sides,
|
||||
/// besides one plain photo.
|
||||
|
||||
@@ -294,6 +294,60 @@ public sealed class IntegrateTests(TestContext context)
|
||||
Assert.True((await builder.BuildAsync(pair, f.Remote, owner, f.Ct)).Can.DeleteThere);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheJobOfAnOwnerWhoIsNotAnAdminPlansWhatTheDialogPlanned()
|
||||
{
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (engine, _) = Engine(f);
|
||||
await using var _ = engine;
|
||||
await engine.StartAsync(f.Ct);
|
||||
var local = await LocalAsync(f, "Comet", [(1, 0, "IMG_0001.JPG"), (4, 30_250, "IMG_0004.JPG")]);
|
||||
var names = await NamesAsync(f, local.Id);
|
||||
var remote = Remote(f, "Comet", [(1, 0, names[0]), (5, 30_250, names[1])]);
|
||||
remote.OwnerUserId = Guid.NewGuid();
|
||||
var pair = await PairAsync(f, local.Id, remote.Id);
|
||||
// An Editor who owns the server sequence: the Delete right, not the admin role.
|
||||
var owner = PlanContext() with { OwnsOrAdmin = false, UserId = remote.OwnerUserId };
|
||||
var plan = await Planner(f).PlanAsync(f.Remote, pair, await ChoicesAsync(f, local.Id, remote.Id, CopyPhotoPolicy.ThisPcWins), owner, f.Ct);
|
||||
Assert.Contains(plan.Photos, p => p.Action == PhotoAction.TrashThere);
|
||||
// The context the job plans with gives the same plan.
|
||||
var queued = IntegrateJobContext.From(owner);
|
||||
Assert.Equal(owner.UserId, queued.ToPlanContext().UserId);
|
||||
Assert.Equal(plan.Fingerprint, (await Planner(f).PlanAsync(f.Remote, pair, plan.Choices, queued.ToPlanContext(), f.Ct)).Fingerprint);
|
||||
|
||||
var job = await CopyJobs.EnqueueIntegrateAsync(engine, f.Sync.Copies, plan, local.DisplayTitle, f.Ct);
|
||||
await f.Archive.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
Assert.Equal(Sha(5, 30_250), f.Remote.Trashed.Single().Frame.Sha256);
|
||||
Assert.True(RemoteHashes(remote).SetEquals([Sha(1, 0), Sha(4, 30_250)]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheJobOfAnOwnerWithoutTheEditRightSendsWhatTheDialogAllowed()
|
||||
{
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (engine, _) = Engine(f);
|
||||
await using var _ = engine;
|
||||
await engine.StartAsync(f.Ct);
|
||||
var local = await LocalAsync(f, "Comet", [(1, 0, "IMG_0001.JPG"), (2, 10_000, "IMG_0002.JPG")]);
|
||||
var names = await NamesAsync(f, local.Id);
|
||||
var remote = Remote(f, "Comet", [(1, 0, names[0])]);
|
||||
remote.OwnerUserId = Guid.NewGuid();
|
||||
var pair = await PairAsync(f, local.Id, remote.Id);
|
||||
// Upload but not Edit: photos may go into a sequence the account owns.
|
||||
var owner = PlanContext(canDelete: false) with { CanEdit = false, UserId = remote.OwnerUserId };
|
||||
var choices = await ChoicesAsync(f, local.Id, remote.Id, CopyPhotoPolicy.Union);
|
||||
var plan = await Planner(f).PlanAsync(f.Remote, pair, choices, owner, f.Ct);
|
||||
Assert.Contains(plan.Photos, p => p.Action is PhotoAction.Send or PhotoAction.SendVersion);
|
||||
Assert.DoesNotContain(CopyBlock.NoAddRight, plan.Blocks);
|
||||
Assert.Equal(plan.Fingerprint, (await Planner(f).PlanAsync(f.Remote, pair, choices, IntegrateJobContext.From(owner).ToPlanContext(), f.Ct)).Fingerprint);
|
||||
|
||||
var job = await CopyJobs.EnqueueIntegrateAsync(engine, f.Sync.Copies, plan, local.DisplayTitle, f.Ct);
|
||||
await f.Archive.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
Assert.True(RemoteHashes(remote).SetEquals([Sha(1, 0), Sha(2, 10_000)]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task WithoutTheDeleteRightTheServersVersionStaysOutOfItsMainAndTheRestRuns()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user