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
@@ -177,6 +177,39 @@ public sealed class SyncServiceCopyTests(TestContext context)
|
||||
Assert.True(pair.NeedsAttention);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequenceReadAsDeletedOnTheServerIsClearedWhenItIsListedAgainOrLinkedAgain()
|
||||
{
|
||||
await using var f = await SyncFixture.CreateAsync(context);
|
||||
var nas = new FakeSyncRemote { Server = HomeFolders.IdKey(Guid.NewGuid()) };
|
||||
var photos = f.NewPhotos(2);
|
||||
var local = await f.LocalAsync("Comet", photos);
|
||||
var remote = nas.Add("Comet", photos);
|
||||
await f.Sync.LinkAsync(nas.Server, remote.Id, local.Id, f.Ct);
|
||||
await f.Sync.RefreshAsync(nas, new SyncPolicy(), f.Ct);
|
||||
nas.Sequences.Remove(remote.Id);
|
||||
await f.Sync.RefreshAsync(nas, new SyncPolicy(), f.Ct);
|
||||
var pair = (await f.Sync.Copies.ListByServerAsync(nas.Server, f.Ct)).Single();
|
||||
await using (var session = await f.Db.Database.OpenAsync(f.Ct))
|
||||
await session.ExecuteAsync("UPDATE found_copies SET remote_gone_at = $1 WHERE id = $2", [DateTimeOffset.UtcNow.AddMinutes(-11), pair.Id], f.Ct);
|
||||
await f.Sync.RefreshAsync(nas, new SyncPolicy(), f.Ct);
|
||||
Assert.True((await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!.RemoteGone);
|
||||
|
||||
// Restored from the server's trash: listed again, it no longer reads "deleted on server".
|
||||
nas.Sequences[remote.Id] = remote;
|
||||
await f.Sync.RefreshAsync(nas, new SyncPolicy(), f.Ct);
|
||||
pair = (await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!;
|
||||
Assert.Equal((0, (DateTimeOffset?)null, false), (pair.RemoteGoneHits, pair.RemoteGoneAt, pair.RemoteGone));
|
||||
Assert.Equal(CopyState.Candidate, pair.State);
|
||||
|
||||
// A pair still marked (the listing missed it) is cleared by a link to that very sequence: automatic photos may move again.
|
||||
await using (var session = await f.Db.Database.OpenAsync(f.Ct))
|
||||
await session.ExecuteAsync("UPDATE found_copies SET remote_gone_hits = 2, remote_gone_at = $1 WHERE id = $2", [DateTimeOffset.UtcNow, pair.Id], f.Ct);
|
||||
await f.Sync.LinkAsync(nas.Server, remote.Id, local.Id, f.Ct);
|
||||
pair = (await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!;
|
||||
Assert.Equal((0, false, CopyState.Linked), (pair.RemoteGoneHits, pair.RemoteGone, pair.State));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequenceBackOnTheServerIsAskedAboutAgain()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user