fix(copies): close the sixth verification round of owner review 6

A merge that finds the other changed drops its journal so the retry plans
again. Unlink and Keep apart name the local side and leave a link that now
joins another sequence alone; Link only and the Integrate job refuse to
touch a link or a pair another integration holds. A sweep of 404s asks the
server once. To trash... trashes from the kept sequence after a swap and
every trash re-checks for new last copies. The Compare dialog and Settings
choices fit in every language, Details segments say which value they take,
twins need their sibling at the other home, and a linked row keeps three
buttons. Captures updated for the dialog and Settings scenes.

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 21:58:58 +01:00
1 parent bf7701d279
commit 38764972ad
77 files changed
+965 -123

No files matched your search

+15 -10
View File
@@ -186,7 +186,7 @@ public sealed class SyncService
var sweep = gone.Count(l => l.LocalId is not null) >= SweepLinks && found == 0;
if (sweep) Log.Warning(LogCategory, $"Every linked sequence of {remote.Server} answered 404 at once ({gone.Count}): none is marked deleted on the server");
foreach (var link in gone) await ForgetAsync(link, sweep ? null : refreshId, cancellationToken).ConfigureAwait(false);
await AskGoneAgainAsync(remote, listing, refreshId, cancellationToken).ConfigureAwait(false);
await AskGoneAgainAsync(remote, listing, refreshId, confirm: !sweep, cancellationToken).ConfigureAwait(false);
}
finally
{
@@ -250,20 +250,24 @@ public sealed class SyncService
/// <summary>
/// Unlinks a server sequence from its local copy (owner review 6, #73): the link stays as an observation of the server's
/// sequence, the local copy reads as this PC's only, and the pair is kept apart (asked again only by a large later change).
/// Nothing happens when the server sequence has no local copy.
/// Nothing happens when the server sequence is not linked to <paramref name="localId"/> (no local copy, or another one:
/// that pair's link and state are not this one's to change). A pair being integrated is refused.
/// </summary>
public async Task UnlinkAsync(string server, Guid remoteId, CancellationToken cancellationToken = default)
public async Task UnlinkAsync(string server, Guid remoteId, Guid localId, CancellationToken cancellationToken = default)
{
await _gate.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
if (await _links.GetAsync(server, remoteId, cancellationToken).ConfigureAwait(false) is not { LocalId: { } localId } link) return;
if (await _links.GetAsync(server, remoteId, cancellationToken).ConfigureAwait(false) is not { LocalId: { } linked } link || linked != localId) return;
var row = await Copies.FindRemoteAsync(localId, server, remoteId, cancellationToken).ConfigureAwait(false);
if (row is { State: CopyState.Integrating }) throw new InvalidOperationException(Loc.L("Errors.Copies.Busy"));
await _links.UpsertAsync(Unlinked(link), cancellationToken).ConfigureAwait(false);
await _links.SetLocalStateAsync(localId, SyncState.LocalOnly, cancellationToken).ConfigureAwait(false);
var row = await Copies.FindRemoteAsync(localId, server, remoteId, cancellationToken).ConfigureAwait(false)
?? await Copies.EnsureLinkedAsync(server, remoteId, localId, cancellationToken).ConfigureAwait(false);
await Copies.SetStateAsync(row.Id, null, CopyState.KeptApart, new CopyAnswer(row.Fingerprint, row.Score.Shared, null, false, DateTimeOffset.UtcNow),
cancellationToken).ConfigureAwait(false);
row ??= await Copies.EnsureLinkedAsync(server, remoteId, localId, cancellationToken).ConfigureAwait(false);
// From the state read: a pair that entered an integration since is left to it.
if (!await Copies.SetStateAsync(row.Id, row.State, CopyState.KeptApart,
new CopyAnswer(row.Fingerprint, row.Score.Shared, null, false, DateTimeOffset.UtcNow), cancellationToken).ConfigureAwait(false))
Log.Warning(LogCategory, $"{link.Title} unlinked; its pair changed meanwhile and keeps its state");
Log.Info(LogCategory, $"{link.Title} unlinked from its copy on this PC");
}
finally
@@ -794,7 +798,7 @@ public sealed class SyncService
/// pair read "deleted on server". A refresh's first 404 forgot the link (the pair is asked about again); a job's 404
/// kept it (the pair stays Linked or Integrated).
/// </summary>
private async Task AskGoneAgainAsync(ISyncRemote remote, IReadOnlyList<SequenceDto> listing, Guid refreshId, CancellationToken cancellationToken)
private async Task AskGoneAgainAsync(ISyncRemote remote, IReadOnlyList<SequenceDto> listing, Guid refreshId, bool confirm, CancellationToken cancellationToken)
{
var listed = listing.Select(d => d.Id).ToHashSet();
var now = DateTimeOffset.UtcNow;
@@ -806,7 +810,8 @@ public sealed class SyncService
await BackAsync(pair, remoteId).ConfigureAwait(false);
continue;
}
if (pair.RemoteGoneAt is { } at && now - at < GoneRecheck) continue;
// A sweep of 404s (the server serves something else now) confirms no earlier hit either.
if (!confirm || (pair.RemoteGoneAt is { } at && now - at < GoneRecheck)) continue;
try
{
await remote.GetSequenceAsync(remoteId, cancellationToken).ConfigureAwait(false);