fix(copies): close the fifth verification round of owner review 6
The metered hold now records the jobs it paused in the index and forgets any job the user pauses, resumes, retries or cancels, so it never resumes a pause of the user's and still resumes its own after a restart. Drop... reports why its dry run is blocked instead of asking first, and dropping the version Main uses lets Main use the version that stays, with its hero and keyframes. That version reads "In Main". Merges: - A re-plan no longer hashes the other's photos again. - A resumed merge verifies photos flagged damaged while it waited. - A merge is blocked while the other's folder holds photos the index has not read; this is checked again under the lease before the trash. - Choose each offers Keep both, Kept and Other, and blocks until every differing photo is chosen. - Classes are named by role. The Compare dialog: - Its headings stay over their columns. - The Projects part scrolls. - Every confirmation line carries its own prefix, and a merge's facts carry none. - A server card in a match offers Compare... alone. The Italian strings follow the glossary. Finding 9 (a local drop counting 0 photos) is not reproduced; a test now keeps the count at 2. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2c06e7ac2b
commit
bf7701d279
159 files changed
+1759
-126
No files matched your search
@@ -320,6 +320,92 @@ public sealed class CopyEngineTests(TestContext context)
|
||||
Assert.True((await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct)).Any(fr => fr.Sha256 == Sha(a)));
|
||||
}
|
||||
|
||||
/// <summary>The photos Main leaves out of <paramref name="sequenceId"/>, by content.</summary>
|
||||
private static async Task<IReadOnlySet<string>> ExcludedAsync(SyncFixture f, Guid sequenceId)
|
||||
{
|
||||
var row = (await f.Db.Sequences.GetAsync(sequenceId))!;
|
||||
return CopyPayload.ExcludedKeys(CopyPayload.Portable(SyncPayload.Of(row), await SequencePayloadWriter.PhotosAsync(f.Db, sequenceId, null, f.Ct)));
|
||||
}
|
||||
|
||||
/// <summary>Main of <paramref name="sequenceId"/> leaves out <paramref name="key"/>, as a Union keep-both leaves the incoming version.</summary>
|
||||
private static async Task ExcludeAsync(SyncFixture f, Guid sequenceId, string key)
|
||||
{
|
||||
var row = (await f.Db.Sequences.GetAsync(sequenceId))!;
|
||||
var portable = CopyPayload.Portable(SyncPayload.Of(row), await SequencePayloadWriter.PhotosAsync(f.Db, sequenceId, null, f.Ct));
|
||||
await new SequencePayloadWriter(f.Db, f.Archive.Service).ApplyAsync(sequenceId, CopyPayload.ExcludeVersions(portable, [key]), row.SettingsVersion, f.Ct);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DroppingTheVersionMainUsesLetsMainUseTheOneThatStays()
|
||||
{
|
||||
// A Union keep-both excluded version B in Main; the user drops A, the one Main used: Main must not be left without
|
||||
// the photo (owner review 6, verification round 5).
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (local, _, a, b) = await VersionsAsync(f);
|
||||
await ExcludeAsync(f, local.Id, Sha(b));
|
||||
Assert.SequenceEqual([Sha(b)], await ExcludedAsync(f, local.Id));
|
||||
using var engine = Engine(f);
|
||||
var photo = (await engine.VersionsAsync(local.Id, f.Ct)).Single();
|
||||
var (frameA, aExcluded, bExcluded) = photo.FirstSha256 == Sha(a)
|
||||
? (photo.FirstFrameId, photo.FirstExcluded, photo.SecondExcluded)
|
||||
: (photo.SecondFrameId, photo.SecondExcluded, photo.FirstExcluded);
|
||||
Assert.Equal((false, true), (aExcluded, bExcluded));
|
||||
|
||||
var plan = await engine.PlanDropOwnVersionAsync(local.Id, frameA, f.Ct);
|
||||
Assert.Equal(1, await engine.DropOwnVersionAsync(plan, f.Ct));
|
||||
|
||||
Assert.Empty(await ExcludedAsync(f, local.Id));
|
||||
Assert.True((await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct)).Any(fr => fr.Sha256 == Sha(b)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task KeepVersionMovesTheExclusionHeroAndKeyframesToTheVersionThatStays()
|
||||
{
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (local, _, a, b) = await VersionsAsync(f);
|
||||
await ExcludeAsync(f, local.Id, Sha(b));
|
||||
var row = (await f.Db.Sequences.GetAsync(local.Id))!;
|
||||
var portable = CopyPayload.Portable(SyncPayload.Of(row), await SequencePayloadWriter.PhotosAsync(f.Db, local.Id, null, f.Ct));
|
||||
|
||||
// Main used A and left B out: once A goes, B is used.
|
||||
var kept = CopyPayload.KeepVersion(portable, Sha(b), Sha(a));
|
||||
Assert.NotNull(kept);
|
||||
Assert.Empty(CopyPayload.ExcludedKeys(kept!));
|
||||
// Dropping the excluded one changes nothing in Main.
|
||||
Assert.Null(CopyPayload.KeepVersion(portable, Sha(a), Sha(b)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DropVersionOfTwoLocalSequencesCountsAPhotoOnEachSide()
|
||||
{
|
||||
// Finding 9 said a pair of this PC's sequences listed "0 photos": the plan counts each local side's version.
|
||||
await using var f = await FixtureAsync(context);
|
||||
var (local, _, a, b) = await VersionsAsync(f);
|
||||
var at = ArchiveFixture.Start.AddSeconds(5).AddMilliseconds(250);
|
||||
var plainAt = ArchiveFixture.Start;
|
||||
var other = await f.LocalAsync("Comet copy", [Photos.Jpeg(plainAt, 7001), a, b], capturedAt: [plainAt, at, at]);
|
||||
var pair = await f.Sync.Copies.UpsertFoundAsync(new FoundCopy
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Kind = CopyKind.LocalLocal,
|
||||
LocalId = local.Id,
|
||||
OtherId = other.Id,
|
||||
Evidence = CopyEvidence.Hashes,
|
||||
Fingerprint = "f",
|
||||
}, f.Ct);
|
||||
await ExcludeAsync(f, local.Id, Sha(b));
|
||||
await ExcludeAsync(f, other.Id, Sha(b));
|
||||
using var engine = Engine(f);
|
||||
|
||||
var plan = await engine.PlanDropVersionAsync(pair.Id, Sha(a), null, f.Ct);
|
||||
Assert.Equal((Sha(b), 2), (plan.PartnerKey, plan.Photos));
|
||||
Assert.Equal(2, await engine.DropVersionAsync(plan, null, f.Ct));
|
||||
|
||||
// Both sides' Main now use the version that stays.
|
||||
Assert.Empty(await ExcludedAsync(f, local.Id));
|
||||
Assert.Empty(await ExcludedAsync(f, other.Id));
|
||||
}
|
||||
|
||||
/// <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.
|
||||
|
||||
Reference in new issue
Block a user