fix(analysis): a deep pass that leaves the saved report records that report
A deep pass overtaken by a frames change that keeps the frame count, with a light analysis queued, leaves an analysis.json of that count in place rather than save its own. It then still recorded its own report: the deep status, summary, warning count and Auto values described a report that is not on disk, and the queued light analysis kept that summary until the next deep pass. SaveReport now says whether it saved; when it did not, the pass reads the saved report as a light analysis would and records that one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+64
-10
No files matched your search
@@ -329,6 +329,52 @@ public sealed class AnalysisJobTests(TestContext context)
|
||||
Assert.Equal(analysed.AnalysisJson, row.AnalysisJson);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ADeepAnalysisThatLeavesTheReportInPlaceRecordsThatReport()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Flickering(12));
|
||||
var folder = fx.Folder(sequence);
|
||||
await fx.StartEngineAsync();
|
||||
var first = await fx.EnqueueAsync(ProcessingJobs.DeepAnalysis([sequence.Id]));
|
||||
await fx.WaitForAsync(first.Id, JobState.Done);
|
||||
var measured = SequenceAnalyser.ReadReport(folder, 12)!;
|
||||
|
||||
// A deep analysis starts on the twelve frames on the only worker. Meanwhile another Titano sharing the archive files
|
||||
// them again, at the next frames version, and saves its own analysis of them; this index's scan indexes them, and
|
||||
// their light analysis waits in the queue.
|
||||
fx.Decoder.HoldFrame(0);
|
||||
var overtaken = await fx.EnqueueAsync(ProcessingJobs.DeepAnalysis([sequence.Id]));
|
||||
await fx.Decoder.Holding.Task.WaitAsync(TimeSpan.FromSeconds(60), fx.Ct);
|
||||
fx.Decoder.Hold = null;
|
||||
var manifest = ManifestStore.ReadSequence(folder.ManifestPath);
|
||||
ManifestStore.WriteSequence(folder.ManifestPath, manifest with
|
||||
{
|
||||
Versions = manifest.Versions with { Frames = manifest.Versions.Frames + 1 },
|
||||
UpdatedAt = DateTimeOffset.UtcNow,
|
||||
});
|
||||
Assert.Contains(sequence.Id, (await fx.Archive.ScanAsync()).Sequences);
|
||||
var theirs = measured with { HeroIndex = measured.HeroIndex == 5 ? 6 : 5 };
|
||||
theirs.Save(folder.AnalysisPath);
|
||||
var report = await File.ReadAllTextAsync(folder.AnalysisPath, fx.Ct);
|
||||
var light = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id]));
|
||||
fx.Decoder.Release();
|
||||
await fx.WaitForAsync(overtaken.Id, JobState.Done);
|
||||
|
||||
// The pass leaves that report in place, and records it rather than its own: the summary in the index is the one of
|
||||
// the file every reader opens, and the light analysis that follows keeps it.
|
||||
Assert.Equal(report, await File.ReadAllTextAsync(folder.AnalysisPath, fx.Ct));
|
||||
var summary = AnalysisSummary.From(theirs);
|
||||
Assert.NotEqual(AnalysisSummary.From(measured), summary);
|
||||
var row = (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!;
|
||||
Assert.True(row.Status.HasFlag(SequenceStatus.AnalyzedDeep), row.Status.ToString());
|
||||
Assert.Equal(summary, AnalysisSummary.FromJson(row.AnalysisJson!));
|
||||
await fx.WaitForAsync(light.Id, JobState.Done);
|
||||
row = (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!;
|
||||
Assert.True(row.Status.HasFlag(SequenceStatus.AnalyzedDeep), row.Status.ToString());
|
||||
Assert.Equal(summary, AnalysisSummary.FromJson(row.AnalysisJson!));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnAnalysisOvertakenWhileALightAnalysisWaitsRecordsAndThatOneReplacesIt()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user