fix(archive): convert job applies exactly the confirmed plan, resumes safely and watches its space
The convert job planned every sequence again when it ran and checked only the frames version, so a verify, a repaired upload or a tier change between the dry run and the job let it replace photos the confirmed plan had listed as staying unchanged. - Each sequence of a convert job now carries the digest of the photos it converts, each with its SHA-256 (ConvertSequencePlan.Digest, also in the plan's fingerprint). Under the sequence's lease, its sidecar settled, the job plans it again and goes on only while the digest matches; it then pins those photos (convert-<job>.pins), so photos that come in or are verified later stay as they are, a retry included. Stage B checks under the lease that every pinned photo still holds the content converted instead of holding the frames version, so a sequence still receiving uploads converts what was confirmed. - A resumed job settles the journals a crash left in a sequence (a half-done replacement among them) before it plans, and reports a sequence its replacement completed as Converted, never Nothing or a partial swap. - The passes a converted or new sequence needs are queued as soon as its outcome is journaled; the journal records the statuses they follow from and whether they were queued, so a pause, yield, stop or crash no longer loses them. - Staged conversions of a blocked or failed sequence are kept for the retry, which re-verifies and takes them; maintenance keeps a convert job's staging while the job is queued, running or paused, and removes its journal and staging once the job is done or gone from the history. - A dry run counts the sequences of a queued conversion as busy, so the same conversion cannot be confirmed twice. - New sequence copies are owned by the source's owner, else by the requesting user's id (never the user name); a staged copy that vanished fails the sequence instead of leaving its photo out; the job log states how many photos stayed in the source alone. - Free space is measured where the conversion writes: the server takes the tighter of the space path's volume and the archive's own (Unraid cache), the desktop asks Windows (GetDiskFreeSpaceEx), which also measures UNC archives; the job checks again before each sequence and each photo, scaling estimates by the files staged so far, and stops before the volume fills with what it staged kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2d7d461c33b9f257bf57793cc7cf331d0425c14e)
This commit is contained in:
1 parent
f86a151a5d
commit
67a6d51cbe
17 files changed
+1222
-236
No files matched your search
@@ -54,6 +54,7 @@ public sealed class ConvertPlannerTests(TestContext context)
|
||||
|
||||
Assert.Equal((manifest.Id, "Roof", "2026/roof", 7), (plan.SequenceId, plan.Title, plan.Folder, plan.FramesVersion));
|
||||
Assert.SequenceEqual([0], plan.Frames.Select(f => f.Index));
|
||||
Assert.Equal("s0", plan.Frames.Single().Sha256);
|
||||
Assert.SequenceEqual(
|
||||
[(ConvertSkip.SameFormat, 1), (ConvertSkip.NoNativeDecoder, 2), (ConvertSkip.PreviewOnly, 1), (ConvertSkip.Undecodable, 1), (ConvertSkip.Missing, 2),
|
||||
(ConvertSkip.Unhashed, 1)],
|
||||
@@ -219,6 +220,28 @@ public sealed class ConvertPlannerTests(TestContext context)
|
||||
Plan(new ConvertOptions(ConvertTarget.Jpeg, 80), ConvertMode.Replace, Sequence(3, 2)).Fingerprint());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheDigestFollowsThePhotosConvertedAndTheirContent()
|
||||
{
|
||||
var a = Guid.NewGuid();
|
||||
var b = Guid.NewGuid();
|
||||
ConvertSequencePlan Sequence(int version, params (Guid Id, string Sha)[] frames) =>
|
||||
new(Guid.Empty, "Roof", "roof", version, [.. frames.Select((f, i) => new ConvertFramePlan(f.Id, i, $"f{i}", ImageFileFormat.Cr2, 10, 20, f.Sha))], [], []);
|
||||
var reference = Sequence(3, (a, "aa"), (b, "bb")).Digest();
|
||||
Assert.Equal(64, reference.Length);
|
||||
// The frames version and the case of a hash say nothing of what converts.
|
||||
Assert.Equal(reference, Sequence(4, (a, "AA"), (b, "bb")).Digest());
|
||||
Assert.Equal(reference, ConvertSequencePlan.DigestOf([(a, "aa"), (b, "bb")]));
|
||||
// Another content, a photo fewer or more (verified since the plan), the same photos in another order: another digest.
|
||||
Assert.NotEqual(reference, Sequence(3, (a, "aa"), (b, "cc")).Digest());
|
||||
Assert.NotEqual(reference, Sequence(3, (a, "aa")).Digest());
|
||||
Assert.NotEqual(reference, Sequence(3, (a, "aa"), (b, "bb"), (Guid.NewGuid(), "dd")).Digest());
|
||||
Assert.NotEqual(reference, Sequence(3, (b, "bb"), (a, "aa")).Digest());
|
||||
// The plan's fingerprint pins the content too: as many photos of the same size holding other content is another plan.
|
||||
ConvertPlan Plan(ConvertSequencePlan sequence) => new(Guid.Empty, new ConvertOptions(ConvertTarget.LinearDng), ConvertMode.Replace, [sequence], new ConvertSpace(0, null));
|
||||
Assert.NotEqual(Plan(Sequence(3, (a, "aa"), (b, "bb"))).Fingerprint(), Plan(Sequence(3, (a, "aa"), (b, "cc"))).Fingerprint());
|
||||
}
|
||||
|
||||
/// <summary>A provider that reads CR2 natively by format, and probes the files <paramref name="applies"/> picks (all
|
||||
/// by default) at a fixed tier, the others native.</summary>
|
||||
private sealed class ProbeAs(DecodeTier tier, Func<string, bool>? applies = null) : IImageDecoderProvider
|
||||
|
||||
Reference in new issue
Block a user