fix(copies): close the owner review 6 gaps with tests

Photos not sent: automatic photos of an integrated pair that failed three
times in a row are now told with an error toast that shows the row, and the
row reads "not sent" with the last reason. The matches-found and linked toasts
of background detections run from their Windows notification too.

Maintenance now clears a merge's or an integration's journal whose job is done,
cancelled, or deleted without a cancel and untouched for the history's days.

Tests pin the matches jobs in the priority queue, the owner's defaults (ask
always, union, copy across), the dialog starting from the settings, Choose
each preselecting nothing, no automatic photos for a pair whose server copy
is gone, the repair of a corrupt local frame by an Integrate, and the owner's
whole scenario end to end against a real in-process server.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-17 14:03:23 +01:00
1 parent fe752a0a21
commit d10577b175
18 files changed
+804 -11

No files matched your search

@@ -1,3 +1,4 @@
using Chronos.Core.IO;
using Chronos.Core.Model;
using Chronos.Data.Copies;
using Chronos.Data.Jobs;
@@ -76,6 +77,37 @@ public sealed class SyncAgentCopyTests(TestContext context)
Assert.Count(0, await QueuedAsync(f, JobKind.Download));
}
[Test]
public async Task APairWhoseServerCopyIsGoneQueuesNoAutomaticPhotos()
{
await using var f = await SyncFixture.CreateAsync(context);
// A server keyed by its id, so a 404 counts against the pair (design §7.5).
var nas = new FakeSyncRemote { Server = HomeFolders.IdKey(Guid.NewGuid()) };
var photos = f.NewPhotos(3);
var local = await f.LocalAsync("Comet", photos);
var remote = nas.Add("Comet NAS", photos.Take(2));
await f.Sync.LinkAsync(nas.Server, remote.Id, local.Id, f.Ct);
var row = await f.Sync.Copies.EnsureLinkedAsync(nas.Server, remote.Id, local.Id, f.Ct);
Assert.True(await f.Sync.Copies.SetStateAsync(row.Id, null, CopyState.Integrated,
new CopyAnswer(null, null, null, true, DateTimeOffset.UtcNow), f.Ct));
nas.Drop(remote.Id);
await using var engine = new JobEngine(f.Db, [.. f.Sync.CreateJobHandlers(new SyncFixture.Connector(nas))],
new JobEngineOptions { Workers = 1, WorkerId = "test", PollInterval = TimeSpan.FromMilliseconds(50) });
await using var agent = new SyncAgent(f.Sync, nas, () => new SyncPolicy(), engine, Quick);
await agent.RefreshAsync(f.Ct);
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), row.Id], f.Ct);
await agent.RefreshAsync(f.Ct);
var pair = (await f.Sync.Copies.GetAsync(row.Id, f.Ct))!;
Assert.True(pair.RemoteGoneHits > 0);
Assert.Equal((CopyState.Integrated, true), (pair.State, pair.AutoPhotos));
Assert.Count(0, await QueuedAsync(f, JobKind.UploadCommit));
Assert.Count(0, await QueuedAsync(f, JobKind.Download));
Assert.Count(0, agent.PhotoFailures);
}
[Test]
public async Task FailedTransfersCountWaitForTheirBackoffAndThreeInARowAreTold()
{