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

@@ -201,7 +201,8 @@ public sealed class ArchiveMaintenance
/// stays while a retry can use it, and goes once the job is done. A job this index does not know (another host's on a
/// shared archive, or one its history forgot) may still be resumed where it is known: its journal and staged conversions
/// stay together while any of them was written within as long as the job history keeps jobs, then go together (staged
/// conversions without a journal, which no resume can use, once idle for a day).
/// conversions without a journal, which no resume can use, once idle for a day). The journal of a merge or an integration
/// goes once its job is done or cancelled, or once this index does not know the job and nothing wrote it for as long.
/// </summary>
private async Task<List<string>> PurgeTemporaryFilesAsync(ArchivePaths paths, IReadOnlyList<SequenceLocation> locations, bool dryRun,
CancellationToken cancellationToken)
@@ -270,6 +271,16 @@ public sealed class ArchiveMaintenance
var state = await StateAsync(job).ConfigureAwait(false);
if (state == JobState.Done || state is null && Expired(job)) found.Add(file);
}
// A merge's or an integration's journal (owner review 6, #73): its job deletes it when it ends or is cancelled, and
// keeps it after a failure for a retry. One whose job ended anyway (a crash before the delete), or that this index
// no longer knows (a job deleted without a cancel, forgotten by the history, or another host's) and that nothing
// wrote for as long as the history keeps jobs, has no retry left to serve.
foreach (var file in Directory.EnumerateFiles(paths.JournalDirectory, "*.json"))
{
if (CopyJournalJob(Path.GetFileName(file)) is not { } job) continue;
var state = await StateAsync(job).ConfigureAwait(false);
if (state is JobState.Done or JobState.Cancelled || state is null && Old(file, JournalAge)) found.Add(file);
}
}
Collect(paths.MetaDirectory, ".*.tmp", TempAge, recursive: false);
foreach (var location in locations)
@@ -296,6 +307,20 @@ public sealed class ArchiveMaintenance
return found.ConvertAll(paths.ToRelative);
}
/// <summary>The journal prefixes of the matches' jobs (<see cref="MergeJournal"/>, <c>IntegrateJournal</c>): "&lt;prefix&gt;&lt;job:N&gt;.json".</summary>
private static readonly string[] CopyJournalPrefixes = ["merge-", "integrate-"];
/// <summary>The job a merge's or an integration's journal belongs to; null for any other file.</summary>
internal static Guid? CopyJournalJob(string name)
{
if (!name.EndsWith(".json", StringComparison.Ordinal)) return null;
foreach (var prefix in CopyJournalPrefixes)
{
if (name.StartsWith(prefix, StringComparison.Ordinal) && Guid.TryParseExact(name[prefix.Length..^".json".Length], "N", out var job)) return job;
}
return null;
}
private async Task<List<string>> CompactPacksAsync(ArchivePaths paths, IReadOnlyList<SequenceLocation> locations, bool dryRun, CancellationToken cancellationToken)
{
var compacted = new List<string>();