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:
1 parent
3e6110d329
commit
3c99badcfe
96 files changed
+910
-147
No files matched your search
@@ -152,6 +152,7 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
Stage = MergeStage.Copy,
|
||||
KeepSettingsVersion = plan.KeepSettingsVersion,
|
||||
DropFramesVersion = plan.DropFramesVersion,
|
||||
DropSettingsVersion = plan.DropSettingsVersion,
|
||||
KeepStatus = (int)keepRow.Status,
|
||||
Copies = [.. plan.Photos.Where(p => p.Action is PhotoAction.Fetch or PhotoAction.FetchVersion && p.FrameId is not null)
|
||||
.Select(p => new MergeCopy(p.Key, p.Action, p.FrameId!.Value, p.FileName, p.Bytes, p.Sha256))],
|
||||
@@ -485,6 +486,9 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
var lost = failed.Where(f => !others.Contains(f.Sha256)).Select(f => f.Sha256).Distinct(StringComparer.Ordinal).Count();
|
||||
if (lost > 0) throw new InvalidOperationException(Loc.Plural("Errors.Copies.VerifyFailed", lost));
|
||||
journal.Settled.AddRange(failed.Select(f => f.FrameId));
|
||||
// Held by a third sequence now: asked again before the trash, which that sequence may not wait for.
|
||||
foreach (var sha in failed.Select(f => f.Sha256).Distinct(StringComparer.Ordinal))
|
||||
if (!journal.SettledElsewhere.Contains(sha)) journal.SettledElsewhere.Add(sha);
|
||||
}
|
||||
journal.VerifiedDropFramesVersion = drop.FramesVersion;
|
||||
Save();
|
||||
@@ -522,7 +526,7 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
}
|
||||
if (!await WinnerInPlaceAsync(replace.WinnerSha256).ConfigureAwait(false))
|
||||
{
|
||||
Keep(replace, "the version that replaces it is not in place");
|
||||
Keep(replace, Loc.L("Archive.Log.KeptReason.NotInPlace"));
|
||||
continue;
|
||||
}
|
||||
try
|
||||
@@ -530,16 +534,17 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
var plan = await owner.Archives.FrameTrash.PlanDeleteAsync(journal.KeepId, [replace.KeepFrameId], null, _ct, journal.JobId).ConfigureAwait(false);
|
||||
if (!plan.CanDelete)
|
||||
{
|
||||
Keep(replace, string.Join(", ", plan.Blocked));
|
||||
Keep(replace, CopyLog.Reasons(plan.Blocked));
|
||||
continue;
|
||||
}
|
||||
await owner.Archives.FrameTrash.DeleteAsync(plan, null, null, _ct, journal.JobId).ConfigureAwait(false);
|
||||
journal.Replaced.Add(replace.Key);
|
||||
Save();
|
||||
context.Log(Loc.L("Archive.Log.CopyReplaced", replace.FileName));
|
||||
}
|
||||
catch (Exception ex) when (ex is StaleDeletePlanException or IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Keep(replace, ex.Message);
|
||||
Keep(replace, CopyLog.Reason(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -548,7 +553,7 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
{
|
||||
journal.KeptLosers.Add(replace.Key);
|
||||
Save();
|
||||
context.Log($"{replace.FileName}: {why}");
|
||||
context.Log(Loc.L("Archive.Log.CopyKept", replace.FileName, why));
|
||||
}
|
||||
|
||||
/// <summary>Whether a usable frame of the kept sequence holds <paramref name="sha"/>, hashed again.</summary>
|
||||
@@ -608,11 +613,12 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
await RenamesRendersAsync(step.SourceProjectId, copied.Id).ConfigureAwait(false);
|
||||
journal.ProjectsDone.Add(step.SourceProjectId);
|
||||
Save();
|
||||
context.Log(Loc.L("Archive.Log.CopyProject", step.SourceName, step.TargetName));
|
||||
}
|
||||
catch (Exception ex) when (ex is not OperationCanceledException)
|
||||
{
|
||||
failed++;
|
||||
context.Log($"{step.SourceName}: {ex.Message}");
|
||||
context.Log(Loc.L("Archive.Log.CopyProjectKept", step.SourceName, ex.Message));
|
||||
}
|
||||
}
|
||||
if (failed > 0) throw new InvalidOperationException(Loc.Plural("Errors.Copies.ProjectsKept", failed));
|
||||
@@ -689,6 +695,12 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
await context.ReportAsync(Done(), Total, new JobDetail(JobStep.Trash, _dropTitle)).ConfigureAwait(false);
|
||||
if (await owner.Workspace.HasUnsentAsync(journal.DropId, _ct).ConfigureAwait(false))
|
||||
throw new InvalidOperationException(Loc.L("Errors.Copies.Unsent", _dropTitle));
|
||||
if (await WorkSinceThePlanAsync(drop).ConfigureAwait(false))
|
||||
{
|
||||
// Work saved into the other since the plan (sent home, rendered) never reached the kept one: planned again.
|
||||
ForgetJournal();
|
||||
throw Changed(_dropTitle);
|
||||
}
|
||||
var expected = journal.VerifiedDropFramesVersion ?? throw Changed(_dropTitle);
|
||||
if (drop.FramesVersion != expected) throw Changed(_dropTitle);
|
||||
EnsureDropReadable(drop);
|
||||
@@ -711,9 +723,37 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
context.Log(Loc.L("Archive.Log.MergeTrashed", _dropTitle));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the other holds work the plan did not see and nothing copied: details or Main settings saved since (its
|
||||
/// settings version moved), a project made or a version added since (missing from the plan, or another head than the
|
||||
/// one it copied), or a render the kept sequence does not hold.
|
||||
/// </summary>
|
||||
private async Task<bool> WorkSinceThePlanAsync(Sequence drop)
|
||||
{
|
||||
if (journal.DropSettingsVersion is { } settings && drop.SettingsVersion != settings) return true;
|
||||
var planned = journal.Projects.ToDictionary(p => p.SourceProjectId);
|
||||
HashSet<string>? keepHeads = null;
|
||||
foreach (var project in await _db.Projects.ListBySequenceAsync(journal.DropId, includeDeleted: false, _ct).ConfigureAwait(false))
|
||||
{
|
||||
if (project.IsMain) continue;
|
||||
if (planned.TryGetValue(project.Id, out var step) && (project.HeadVersionId ?? Guid.Empty) == step.SourceHeadId) continue;
|
||||
// Not planned (or moved on since) is fine only when the kept sequence holds that head already, as the plan saw it.
|
||||
keepHeads ??= await owner.Merger.HeadHashesAsync(
|
||||
await _db.Projects.ListBySequenceAsync(journal.KeepId, includeDeleted: false, _ct).ConfigureAwait(false), _ct).ConfigureAwait(false);
|
||||
if (!await owner.Merger.HeldAlreadyAsync(project, keepHeads, _ct).ConfigureAwait(false)) return true;
|
||||
}
|
||||
var renders = await _db.Renders.ListBySequenceAsync(journal.DropId, _ct).ConfigureAwait(false);
|
||||
if (renders.Count == 0) return false;
|
||||
// A render the plan left because the kept sequence holds the same file stays with the other, as planned.
|
||||
var keepHashes = (await _db.Renders.ListBySequenceAsync(journal.KeepId, _ct).ConfigureAwait(false)).Select(r => r.Sha256).OfType<string>()
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
return renders.Any(r => !journal.RendersMoved.Contains(r.Id) && (r.Sha256 is null || !keepHashes.Contains(r.Sha256)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Every usable photo of the other was verified (held by the kept sequence, or a last copy the plan listed, or held by
|
||||
/// a third sequence), and every photo the verify found in the kept sequence is still there and usable (read under its lease).
|
||||
/// a third sequence that still holds it now), and every photo the verify found in the kept sequence is still there and
|
||||
/// usable (read under its lease).
|
||||
/// </summary>
|
||||
private async Task EnsureVerifiedHeldAsync()
|
||||
{
|
||||
@@ -723,6 +763,18 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
if (dropFrames.Any(f => (f.Flags & CopySides.UnusableFlags) == 0 && !journal.Verified.ContainsKey(f.Id) && !journal.Settled.Contains(f.Id)))
|
||||
throw Changed(_dropTitle);
|
||||
|
||||
// The photos a third sequence held at the verify: one it no longer holds would leave only with the other, never
|
||||
// listed as a last copy. Planned again, the plan lists it.
|
||||
if (journal.SettledElsewhere.Count > 0)
|
||||
{
|
||||
var still = await new CopySides(_db).HeldElsewhereAsync(journal.SettledElsewhere, [journal.DropId, journal.KeepId], _ct).ConfigureAwait(false);
|
||||
if (journal.SettledElsewhere.Any(sha => !still.Contains(sha)))
|
||||
{
|
||||
ForgetJournal();
|
||||
throw Changed(_dropTitle);
|
||||
}
|
||||
}
|
||||
|
||||
var frames = await ProcessingFrames.ListAsync(_db, journal.KeepId, _ct).ConfigureAwait(false);
|
||||
var byId = frames.Where(f => (f.Flags & CopySides.UnusableFlags) == 0).ToDictionary(f => f.Id);
|
||||
var hashes = byId.Values.Select(f => f.Sha256).OfType<string>().Select(s => s.ToLowerInvariant()).ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
Reference in new issue
Block a user