fix(copies): close the third verification round and add the match baselines

Integrate trashes a server photo only for the sequence's owner or an admin, a
Details stage stops instead of overwriting a server change the user had kept
this PC's value against, a merge retried after a stop plans again when work
reached the other sequence, detection keeps pairs answered while it ran, and a
sync row whose match the server deleted offers Keep here, Upload again and To
trash. The Integrate and merge logs say in the UI language why a version was
kept.

The edit-picker-twins capture scene showed no Twin chip, since a capture has no
workspace: it now lists sample workspace projects of the sample matches. The
screenshot baselines gain the 38 Matches screens and take the Matches chip,
the three Settings > Server rows, the longer priority list and 1.2.0.

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 18:01:37 +01:00
1 parent 3e6110d329
commit 3c99badcfe
96 files changed
+910 -147

No files matched your search

+41 -8
View File
@@ -144,7 +144,7 @@ public sealed class SequenceMerger(ChronosDatabase db, ArchiveService archives,
var losers = steps.Where(s => s.Action == PhotoAction.TrashHere).Select(s => s.FrameId!.Value).ToHashSet();
var keepHolds = here.Photos.Where(p => !p.Unusable && p.Sha256 is { Length: > 0 } && !losers.Contains(p.FrameId))
.Select(p => p.Sha256!.ToLowerInvariant()).ToHashSet(StringComparer.Ordinal);
// Photos of the other a verify flagged Corrupt (changed since import, or damaged) whose file is still there: the
// Photos of the other a verify flagged Corrupt (changed since import, or damaged) or Missing whose file is there: the
// comparison leaves them out, so nothing would copy or hash-verify them before their folder goes to the trash. One
// whose content now nothing else holds (an edited photo's only copy) blocks the merge until it is resolved.
if (online && await DamagedAsync(drop, dropPaths, keepHolds, ct).ConfigureAwait(false)) blocks.Add(CopyBlock.DamagedPhotos);
@@ -281,14 +281,15 @@ public sealed class SequenceMerger(ChronosDatabase db, ArchiveService archives,
}
/// <summary>
/// Whether the other sequence holds a frame flagged Corrupt (not Missing) whose file is still there and whose content,
/// hashed now (in memory), neither the kept sequence (<paramref name="keepHolds"/>) nor any other sequence of this
/// index holds; an unreadable such file counts too.
/// Whether the other sequence holds a frame flagged unusable (Corrupt, or Missing by an earlier verify although its file
/// is back) whose file is there and whose content, hashed now (in memory), neither the kept sequence
/// (<paramref name="keepHolds"/>) nor any other sequence of this index holds; an unreadable such file counts too. The
/// comparison leaves such frames out, so nothing else would copy or list them before their folder goes to the trash.
/// </summary>
private async Task<bool> DamagedAsync(Guid drop, ArchivePaths dropPaths, IReadOnlySet<string> keepHolds, CancellationToken ct)
{
var flagged = (await _db.Frames.ListBySequenceAsync(drop, cancellationToken: ct).ConfigureAwait(false))
.Where(f => (f.Flags & FrameFlags.Corrupt) != 0 && (f.Flags & FrameFlags.Missing) == 0).ToList();
.Where(f => (f.Flags & CopySides.UnusableFlags) != 0).ToList();
var hashes = new List<string>();
foreach (var frame in flagged)
{
@@ -441,15 +442,20 @@ public sealed class SequenceMerger(ChronosDatabase db, ArchiveService archives,
return false;
}
/// <summary>The drop's non-Main projects, each with the name it gets at the kept sequence's home.</summary>
/// <summary>
/// The drop's non-Main projects, each with the name it gets at the kept sequence's home; one whose head the kept
/// sequence's projects hold already (by content: a merge planned again after an earlier run copied it) is not copied again.
/// </summary>
private async Task<List<ProjectStep>> ProjectStepsAsync(Guid keep, Guid drop, string dropArchiveName, CancellationToken ct)
{
var taken = (await _db.Projects.ListBySequenceAsync(keep, includeDeleted: false, ct).ConfigureAwait(false)).Select(p => p.Name)
.ToHashSet(StringComparer.OrdinalIgnoreCase);
var keepProjects = await _db.Projects.ListBySequenceAsync(keep, includeDeleted: false, ct).ConfigureAwait(false);
var taken = keepProjects.Select(p => p.Name).ToHashSet(StringComparer.OrdinalIgnoreCase);
var keepHeads = await HeadHashesAsync(keepProjects, ct).ConfigureAwait(false);
var steps = new List<ProjectStep>();
foreach (var project in (await _db.Projects.ListBySequenceAsync(drop, includeDeleted: false, ct).ConfigureAwait(false))
.Where(p => !p.IsMain).OrderBy(p => p.CreatedAt).ThenBy(p => p.Id))
{
if (await HeldAlreadyAsync(project, keepHeads, ct).ConfigureAwait(false)) continue;
var name = FreeName(project.Name, dropArchiveName, taken);
taken.Add(name);
steps.Add(new ProjectStep(CopySide.Other, project.Id, project.Name, name, project.HeadNumber, project.HeadVersionId ?? Guid.Empty));
@@ -457,6 +463,33 @@ public sealed class SequenceMerger(ChronosDatabase db, ArchiveService archives,
return steps;
}
/// <summary>The content hashes of the heads of <paramref name="projects"/> (Main and versionless ones left out; an unreadable head too).</summary>
internal async Task<HashSet<string>> HeadHashesAsync(IEnumerable<SequenceProject> projects, CancellationToken ct)
{
var hashes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var project in projects.Where(p => !p.IsMain && p.HeadVersionId is not null))
{
if (await HeadHashAsync(project.Id, ct).ConfigureAwait(false) is { } hash) hashes.Add(hash);
}
return hashes;
}
/// <summary>Whether the head of <paramref name="project"/> is one of <paramref name="heads"/> (by content).</summary>
internal async Task<bool> HeldAlreadyAsync(SequenceProject project, IReadOnlySet<string> heads, CancellationToken ct) =>
heads.Count > 0 && project.HeadVersionId is not null && await HeadHashAsync(project.Id, ct).ConfigureAwait(false) is { } head && heads.Contains(head);
private async Task<string?> HeadHashAsync(Guid projectId, CancellationToken ct)
{
try
{
return (await _archives.Projects.HeadAsync(projectId, ct).ConfigureAwait(false)).ContentHash;
}
catch (Exception ex) when (ex is ProjectException or IOException or UnauthorizedAccessException)
{
return null;
}
}
/// <summary>The name itself when free, else "&lt;name&gt; (&lt;archive&gt;)", then " (2)"…, each within <see cref="ProjectService.MaxNameLength"/>.</summary>
internal static string FreeName(string name, string archiveName, IReadOnlySet<string> taken)
{