fix(copies): close the seventh verification round of owner review 6
- A merge plan hashes the kept sequence's unhashed frames that match a hashed photo of the other by size and time: the same content is no longer a false last copy, and another content is copied in as a second version instead of going to the trash with the other sequence. - The Replace stage trashes a losing version of the kept sequence only while another sequence still holds it or the plan listed it as a last copy; otherwise the journal goes and the job fails as a stale plan. - A details conflict at the merge's or the Integrate's Details stage drops the journal, so a retry plans again instead of failing the same way. - The Integrate's Projects stage keeps a project for good only for a permanent refusal; a server out of reach fails the job with the journal kept, and the retry finishes the same copy. - A pair read as deleted on the server is cleared when the server lists it again or a link to that sequence is made. - An upload of a sequence kept apart from a server sequence goes under a session key of the job, making a new server sequence; a link made over a kept-apart pair moves it to Linked. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c3273b7da5
commit
123ceba845
13 files changed
+418
-13
No files matched your search
@@ -143,6 +143,35 @@ public sealed class SyncTransferCopyTests(TestContext context)
|
||||
Assert.True(target.Frames.Select(fr => fr.Sha256).ToHashSet().SetEquals(photos.Select(Sha)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnUploadOfASequenceKeptApartMakesANewServerSequenceAndLeavesTheOtherAlone()
|
||||
{
|
||||
await using var f = Capable(await SyncFixture.CreateAsync(context));
|
||||
var photos = f.NewPhotos(3);
|
||||
var local = await f.LocalAsync("Comet", [photos[0], photos[1]]);
|
||||
var engine = await f.StartEngineAsync();
|
||||
var job = await f.Sync.EnqueueUploadAsync(engine, f.Server, local);
|
||||
await f.Archive.WaitForAsync(job.Id, JobState.Done);
|
||||
var first = Assert.NotNull(await f.Sync.Links.FindByLocalAsync(f.Server, local.Id, f.Ct)).RemoteId;
|
||||
// Unlinked ("Stop syncing these sequences"): the pair is kept apart.
|
||||
await f.Sync.UnlinkAsync(f.Server, first, local.Id, f.Ct);
|
||||
var pair = (await f.Sync.Copies.ListByServerAsync(f.Server, f.Ct)).Single(c => c.RemoteId == first);
|
||||
Assert.Equal(CopyState.KeptApart, pair.State);
|
||||
|
||||
// A new photo, then a plain Upload.
|
||||
await f.AddLocalAsync(local.Id, photos[2]);
|
||||
job = await f.Sync.EnqueueUploadAsync(engine, f.Server, (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!);
|
||||
await f.Archive.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
// The sequence kept apart gets nothing, and stays apart and unlinked; a new one holds every photo.
|
||||
Assert.True(f.Remote.Sequences[first].Frames.Select(fr => fr.Sha256).ToHashSet().SetEquals([Sha(photos[0]), Sha(photos[1])]));
|
||||
Assert.Equal(CopyState.KeptApart, (await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!.State);
|
||||
Assert.Null((await f.Sync.Links.GetAsync(f.Server, first, f.Ct))!.LocalId);
|
||||
var link = Assert.NotNull(await f.Sync.Links.FindByLocalAsync(f.Server, local.Id, f.Ct));
|
||||
Assert.NotEqual(first, link.RemoteId);
|
||||
Assert.True(f.Remote.Sequences[link.RemoteId].Frames.Select(fr => fr.Sha256).ToHashSet().SetEquals(photos.Select(Sha)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnAutomaticUploadAfterTheServerCopyIsGoneFailsAndCreatesNothing()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user