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
@@ -439,21 +439,21 @@ public abstract class FrameTrashTests(TestContext context) : DatabaseTest(contex
|
||||
var (sequence, frames) = await UploadedAsync(fx, 2);
|
||||
var replacement = frames[1];
|
||||
var good = WriteReplaced(fx, sequence, "20261027100000", replacement.Sha256!);
|
||||
var bad = WriteReplaced(fx, sequence, "20261027110000", new string('a', 64));
|
||||
// A replacement no frame of the sequence holds any more (its conversion deleted and erased): the dry run says so, and
|
||||
// the emptying confirmed with it erases the originals (owner review 2, R7).
|
||||
var gone = WriteReplaced(fx, sequence, "20261027110000", new string('a', 64));
|
||||
var engine = await fx.StartEngineAsync();
|
||||
var listed = await fx.Service.ListTrashAsync(fx.Archive.Id, fx.Ct);
|
||||
Assert.True(listed.All(e => e.Kind == TrashKind.Replaced));
|
||||
|
||||
var plan = await fx.Service.PlanEmptyTrashAsync(fx.Archive.Id, null, fx.Ct);
|
||||
Assert.True(plan.Entries.Single(e => e.Name == FrameTrash.EntryPrefix + gone).ConversionDeleted);
|
||||
Assert.False(plan.Entries.Single(e => e.Name == FrameTrash.EntryPrefix + good).ConversionDeleted);
|
||||
var job = await engine.EnqueueAsync(ArchiveJobs.EmptyTrash(fx.Archive, plan), cancellationToken: fx.Ct);
|
||||
var failed = await fx.WaitForAsync(job.Id, JobState.Failed);
|
||||
await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
Assert.Empty(await fx.Service.ListTrashAsync(fx.Archive.Id, fx.Ct));
|
||||
|
||||
Assert.Equal(Chronos.Core.Localization.Loc.Plural("Archive.Error.TrashKept", 1), failed.Error);
|
||||
var left = Assert.Contains(await fx.Service.ListTrashAsync(fx.Archive.Id, fx.Ct), e => e.Name == FrameTrash.EntryPrefix + bad);
|
||||
Assert.Equal(TrashKind.Replaced, left.Kind);
|
||||
Assert.DoesNotContain(FrameTrash.EntryPrefix + good, (await fx.Service.ListTrashAsync(fx.Archive.Id, fx.Ct)).Select(e => e.Name));
|
||||
|
||||
// A replacement whose file no longer hashes to it keeps its originals too.
|
||||
// A replacement whose file no longer hashes to it keeps its originals.
|
||||
var other = WriteReplaced(fx, sequence, "20261027120000", replacement.Sha256!);
|
||||
var file = fx.Paths.FromRelative(replacement.RelativePath);
|
||||
var bytes = File.ReadAllBytes(file);
|
||||
|
||||
Reference in new issue
Block a user