fix(archive): settle conversions by content and keep their aliases through trash, undo, sync and ingest
Owner review 2, phase 4b, fix round 1 (trash, undo, recovery, sync and ingest). - Replace journal: records a phase (moving, written, undoing) and the name each swapped frame is filed under. Recovery decides "sidecar written" by what the sidecar lists, not by the frames version any writer moves; a failed rollback stays undoing and its failure now stops the writer (as a photo deletion's recovery does). The ingest settles restores and replacements first, so an upload can no longer complete a swap that never happened. - Emptying a Replaced entry re-verifies each replacement where it is now: in the sequence through later conversions (a second conversion no longer strands the first originals), or, when the conversion was deleted, its copy in the trash. The dry run marks such entries "conversion deleted" (fingerprinted, shown on the desktop and the panel), and the confirmed emptying may then erase them instead of keeping them forever. - Undo of a conversion takes exactly the entries its job made (the job id is recorded on the entry), never entries found by time window. - Project positions translated by photo use the sidecar's photo of every frame still there, so positions on a converted frame stay put when another frame went meanwhile. - Sync aliases are equivalence classes: an original converted on both sides is one photo; link-by-content, proxy counting and proxy upload follow aliases; a download into a frame missing here swaps the other encoding into that frame instead of adding a frame. - The ingest answers a converted photo's original (a card or folder imported again, a download) as a duplicate of its conversion and keeps the alias tombstone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 3341a2f845753fc4c5bcba51a3b645f126c95eaf)
This commit is contained in:
1 parent
67a6d51cbe
commit
d0bbd77c92
31 files changed
+1326
-211
No files matched your search
@@ -51,9 +51,9 @@ public static class ConvertUndo
|
||||
public static bool Replaces(Job job) => Parameters(job) is { Mode: ConvertMode.Replace };
|
||||
|
||||
/// <summary>
|
||||
/// The trash entries an undo of <paramref name="job"/> restores: of each sequence it converted, the newest entry of replaced
|
||||
/// originals made while it ran (from when it was queued to when it ended, so an entry an undo made of the converted files
|
||||
/// is never taken for the originals).
|
||||
/// The trash entries an undo of <paramref name="job"/> restores: the entries of replaced originals the job itself made
|
||||
/// (each records the job, <see cref="TrashEntry.JobId"/>), still in the trash, oldest first. Never one made by anything
|
||||
/// else meanwhile, such as the entry of converted files a restore from Maintenance › Trash makes while the job runs.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<TrashEntry> Entries(Job job, ConvertJobParameters parameters, IEnumerable<TrashEntry> trash)
|
||||
{
|
||||
@@ -63,10 +63,7 @@ public static class ConvertUndo
|
||||
var converted = parameters.Sequences.Select(s => s.Id).ToHashSet();
|
||||
return
|
||||
[
|
||||
.. trash.Where(e => e.Kind == TrashKind.Replaced && e.ArchiveId == parameters.ArchiveId && converted.Contains(e.SequenceId) && e.DeletedAt >= job.Created
|
||||
&& (job.Finished is not { } finished || e.DeletedAt <= finished))
|
||||
.GroupBy(e => e.SequenceId)
|
||||
.Select(g => g.MaxBy(e => e.DeletedAt)!)
|
||||
.. trash.Where(e => e.Kind == TrashKind.Replaced && e.JobId == job.Id && e.ArchiveId == parameters.ArchiveId && converted.Contains(e.SequenceId))
|
||||
.OrderBy(e => e.DeletedAt),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -38,14 +38,19 @@ public static class TrashEmptyPlans
|
||||
/// <summary>"Photos", "Sequence", "Replaced".</summary>
|
||||
public static string KindText(TrashKind kind) => Loc.L("Archive.Trash.Kind." + kind);
|
||||
|
||||
/// <summary>The confirmation of erasing the planned entries for good; null when the plan holds none.</summary>
|
||||
/// <summary>
|
||||
/// The confirmation of erasing the planned entries for good; null when the plan holds none. An entry of replaced originals
|
||||
/// whose conversion was deleted since says so (<see cref="TrashEntry.ConversionDeleted"/>): erasing it may erase the last
|
||||
/// copy of those photos.
|
||||
/// </summary>
|
||||
public static ConfirmRequest? Request(TrashEmptyPlan plan)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
if (plan.Entries.Count == 0) return null;
|
||||
var count = plan.Entries.Count.ToString(CultureInfo.InvariantCulture);
|
||||
var lines = plan.Entries.Take(DeletePlans.ListedLines).Select(e => Loc.L("Archive.Delete.Line", e.Title,
|
||||
KindText(e.Kind) + Loc.Separator + Loc.Plural("Shell.Status.Photos", e.Frames), Formatting.Bytes(e.Bytes))).ToList();
|
||||
KindText(e.Kind) + Loc.Separator + Loc.Plural("Shell.Status.Photos", e.Frames)
|
||||
+ (e.ConversionDeleted ? Loc.Separator + Loc.L("Archive.Trash.ConversionDeleted") : string.Empty), Formatting.Bytes(e.Bytes))).ToList();
|
||||
if (plan.Entries.Count > DeletePlans.ListedLines) lines.Add(Loc.Plural("Archive.Delete.More", plan.Entries.Count - DeletePlans.ListedLines));
|
||||
return new ConfirmRequest
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user