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
@@ -287,7 +287,7 @@ public sealed class ConvertDialogTests(TestContext context)
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheUndoTakesTheNewestReplacedEntryOfEachSequenceTheJobConverted()
|
||||
public void TheUndoTakesTheReplacedEntriesTheJobMade()
|
||||
{
|
||||
var archive = Guid.CreateVersion7();
|
||||
var (harbour, comet, other) = (Guid.CreateVersion7(), Guid.CreateVersion7(), Guid.CreateVersion7());
|
||||
@@ -303,21 +303,22 @@ public sealed class ConvertDialogTests(TestContext context)
|
||||
Created = created,
|
||||
Finished = created.AddMinutes(10),
|
||||
};
|
||||
TrashEntry Entry(string name, Guid sequence, int minutes, TrashKind kind = TrashKind.Replaced, Guid? owner = null) =>
|
||||
new(owner ?? archive, name, sequence, name, "2026/" + name, 3, 3, 3_000, created.AddMinutes(minutes), null, kind);
|
||||
TrashEntry Entry(string name, Guid sequence, int minutes, Guid? madeBy, TrashKind kind = TrashKind.Replaced, Guid? owner = null) =>
|
||||
new(owner ?? archive, name, sequence, name, "2026/" + name, 3, 3, 3_000, created.AddMinutes(minutes), null, kind) { JobId = madeBy };
|
||||
TrashEntry[] trash =
|
||||
[
|
||||
Entry("before", harbour, -5),
|
||||
Entry("first", harbour, 2),
|
||||
Entry("second", harbour, 4),
|
||||
Entry("comet", comet, 6),
|
||||
Entry("deleted", comet, 7, TrashKind.Photos),
|
||||
Entry("other", other, 5),
|
||||
Entry("elsewhere", harbour, 5, owner: Guid.CreateVersion7()),
|
||||
Entry("undo", comet, 12),
|
||||
Entry("before", harbour, -5, Guid.CreateVersion7()),
|
||||
Entry("harbour", harbour, 2, job.Id),
|
||||
// A restore from Maintenance › Trash while the job ran: the converted files of its swap-back, made by no job.
|
||||
Entry("restored", harbour, 4, null),
|
||||
Entry("comet", comet, 6, job.Id),
|
||||
Entry("deleted", comet, 7, job.Id, TrashKind.Photos),
|
||||
Entry("other", other, 5, job.Id),
|
||||
Entry("elsewhere", harbour, 5, job.Id, owner: Guid.CreateVersion7()),
|
||||
Entry("undo", comet, 12, null),
|
||||
];
|
||||
|
||||
Assert.SequenceEqual(["second", "comet"], ConvertUndo.Entries(job, parameters, trash).Select(e => e.Name));
|
||||
Assert.SequenceEqual(["harbour", "comet"], ConvertUndo.Entries(job, parameters, trash).Select(e => e.Name));
|
||||
Assert.True(ConvertUndo.Replaces(job));
|
||||
Assert.False(ConvertUndo.Replaces(job with { ParametersJson = job.ParametersJson!.Replace("\"Replace\"", "\"NewSequence\"", StringComparison.Ordinal) }));
|
||||
Assert.False(ConvertUndo.Replaces(job with { Kind = JobKind.Move }), "only a conversion");
|
||||
|
||||
@@ -60,7 +60,14 @@ public sealed class TrashDialogTests(TestContext context)
|
||||
var lines = request.Detail!.Split(Environment.NewLine);
|
||||
Assert.Equal(2, lines.Length);
|
||||
Assert.Contains(Loc.L("Archive.Trash.Kind.Photos"), lines[0]);
|
||||
Assert.False(request.Detail!.Contains(Loc.L("Archive.Trash.ConversionDeleted"), StringComparison.Ordinal), "no conversion was deleted");
|
||||
Assert.Null(TrashEmptyPlans.Request(plan with { Entries = [] }), "nothing to erase: no confirmation");
|
||||
|
||||
// Replaced originals whose conversion was deleted since: the line says so, as the dry run found it.
|
||||
var replaced = Entry("Etna", TrashKind.Replaced, 3, 90_000_000) with { ConversionDeleted = true };
|
||||
var lone = Assert.NotNull(TrashEmptyPlans.Request(plan with { Entries = [replaced] }));
|
||||
Assert.Contains(Loc.L("Archive.Trash.Kind.Replaced") + Loc.Separator + Loc.Plural("Shell.Status.Photos", 3) + Loc.Separator
|
||||
+ Loc.L("Archive.Trash.ConversionDeleted"), lone.Detail!);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user