Merge branch 'fix/imaging-metadata': decode tiers, preview-only and undecodable frames, GPR companions, MakerNote fields
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
70 files changed
+2201
-124
No files matched your search
@@ -88,6 +88,60 @@ public sealed class ArchiveJobTests(TestContext context)
|
||||
Assert.Contains("made 3, reused 3", done.LogTail);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AThumbnailPassFlagsFramesNothingDecodesAndClearsThemOnceTheyDecode()
|
||||
{
|
||||
await using var fx = await CreateAsync(context);
|
||||
var files = Photos.WriteSeries(Path.Combine(fx.Paths.Root, "a"), Start, 6);
|
||||
await fx.ScanAsync();
|
||||
var a = (await LocationsAsync(fx))[0];
|
||||
var sequence = (await fx.Db.Sequences.GetAsync(a.Id))!;
|
||||
var paths = fx.Paths.Sequence(a.Folder);
|
||||
var original = await File.ReadAllBytesAsync(files[2], fx.Ct);
|
||||
await File.WriteAllBytesAsync(files[2], new byte[original.Length], fx.Ct);
|
||||
|
||||
var result = await fx.Service.Images.BuildThumbnailsAsync(fx.Archive, sequence, false, 0, (_, _) => ValueTask.CompletedTask, fx.Ct);
|
||||
|
||||
Assert.Equal((5, 1), (result.Built, result.Undecodable));
|
||||
var frame = ManifestStore.ReadSequence(paths.ManifestPath).Frames[2];
|
||||
Assert.Equal((Titano.Core.Imaging.DecodeTier.Unavailable, FrameFlags.Undecodable), (frame.Tier, frame.Flags));
|
||||
Assert.Equal(FrameFlags.Undecodable, (await fx.Db.Frames.ListBySequenceAsync(a.Id))[2].Flags);
|
||||
Assert.True((await fx.Db.Sequences.GetAsync(a.Id))!.Status.HasFlag(SequenceStatus.HasWarnings), "the sequence warns at once");
|
||||
|
||||
// Restored from a copy: the next pass decodes the frame and clears the flag; the others are reused.
|
||||
await File.WriteAllBytesAsync(files[2], original, fx.Ct);
|
||||
result = await fx.Service.Images.BuildThumbnailsAsync(fx.Archive, sequence, false, 0, (_, _) => ValueTask.CompletedTask, fx.Ct);
|
||||
Assert.Equal((1, 5, 0), (result.Built, result.Reused, result.Undecodable));
|
||||
frame = ManifestStore.ReadSequence(paths.ManifestPath).Frames[2];
|
||||
Assert.Equal((Titano.Core.Imaging.DecodeTier.Native, FrameFlags.None), (frame.Tier, frame.Flags));
|
||||
Assert.Equal(FrameFlags.None, (await fx.Db.Frames.ListBySequenceAsync(a.Id))[2].Flags);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AHostWithoutADecoderForTheFormatRecordsTheTierWithoutFlaggingTheFrames()
|
||||
{
|
||||
// The fixture's decoder chain is empty: only JPEG decodes here (its decoder is built in), PNG does not.
|
||||
await using var fx = await CreateAsync(context);
|
||||
var folder = Path.Combine(fx.Paths.Root, "p");
|
||||
Directory.CreateDirectory(folder);
|
||||
using (var image = new Titano.Core.Imaging.ImageBuffer(32, 24))
|
||||
{
|
||||
for (var i = 0; i < 3; i++) File.WriteAllBytes(Path.Combine(folder, $"P{i}.png"), Titano.Core.Codecs.Png.PngEncoder.Encode(image));
|
||||
}
|
||||
await fx.ScanAsync();
|
||||
var p = (await LocationsAsync(fx)).Single();
|
||||
|
||||
var result = await fx.Service.Images.BuildThumbnailsAsync(fx.Archive, (await fx.Db.Sequences.GetAsync(p.Id))!, false, 0,
|
||||
(_, _) => ValueTask.CompletedTask, fx.Ct);
|
||||
|
||||
// Another host (or a proxy) may still provide the pixels: the tier is recorded, the frames stay renderable.
|
||||
Assert.Equal(3, result.Undecodable);
|
||||
var frames = ManifestStore.ReadSequence(fx.Paths.Sequence(p.Folder).ManifestPath).Frames;
|
||||
Assert.True(frames.All(f => f.Tier == Titano.Core.Imaging.DecodeTier.Unavailable && f.Flags == FrameFlags.None), "tier without flag");
|
||||
Assert.True((await fx.Db.Frames.ListBySequenceAsync(p.Id)).All(f => f.Flags == FrameFlags.None), "index flags");
|
||||
Assert.False((await fx.Db.Sequences.GetAsync(p.Id))!.Status.HasFlag(SequenceStatus.HasWarnings), "no warning");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AMaintenanceJobResumesAfterItsDoneSteps()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user