fix(archive,analysis): an unreadable photo changes nothing; a report stale by proxies never replaces a current one

The orphans fix and scans treated a folder whose only new photo could not be
read yet (held open, no permission, an offline placeholder) as changed: the
sidecar was rewritten, the covering flags cleared and analyses queued again at
every click. SequenceAdopter.Reconcile now returns null when it indexed nothing
and changed no flag, as its contract says.

A deep pass counted as current by frames version alone, so a pass whose verdict
a proxy made stale overwrote the report a later pass made from the proxies,
then dropped the deep status. It now counts as current only when its report
describes the frames as they are, and otherwise replaces only a saved report
that does not describe them either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-13 00:31:30 +00:00
1 parent 00823b0328
commit 0085765a12
4 files changed
+84 -12

No files matched your search

+18 -12
View File
@@ -100,17 +100,22 @@ internal sealed class SequenceAnalyser(TitanoDatabase db, ProcessingOptions opti
{
var manifest = SequenceWriter.ReadLocked(folder, sequence.Id);
var change = await FramesChangeAsync(sequence, manifest, cancellationToken).ConfigureAwait(false);
var saved = deep && SaveReport(folder, report!, change == FramesChange.None && manifest.Versions.Frames == sequence.FramesVersion,
manifest.Frames.Count);
// The frames as this host reads them now: a proxy that arrived while the pass ran moves no frames version but
// makes the pass's verdict on that frame's original stale, so only a report that describes them is current.
var now = deep && change == FramesChange.None
? await SequenceFrames.LoadAsync(db, archive, sequence, useProxies: false, options.Archive.Decoder, cancellationToken).ConfigureAwait(false)
: null;
var saved = deep && SaveReport(folder, report!,
change == FramesChange.None && manifest.Versions.Frames == sequence.FramesVersion && Describes(report!, now!),
now, manifest.Frames.Count);
if (change != FramesChange.None)
return new AnalysisOutcome(sequence, frames.Count, 0, SettingsChanged: false, SettingsUnreadable: false, [], change);
if (deep)
{
// A report left in place is read as a light analysis reads it, so the deep status, summary, warnings and
// Auto values recorded here describe the file that readers and the report endpoint open.
var now = await SequenceFrames.LoadAsync(db, archive, sequence, useProxies: false, options.Archive.Decoder, cancellationToken).ConfigureAwait(false);
if (!saved) report = ReadReport(folder, now);
else if (!Describes(report!, now)) report = null;
if (!saved) report = ReadReport(folder, now!);
else if (!Describes(report!, now!)) report = null;
}
else
{
@@ -255,15 +260,16 @@ internal sealed class SequenceAnalyser(TitanoDatabase db, ProcessingOptions opti
/// <summary>
/// Saves a deep pass's report as <c>analysis.json</c>, under the sequence lock, then drops its checkpoint; returns
/// whether it saved it. The report replaces the saved one when it measured the frames as they are
/// (<paramref name="current"/>), or when the saved one describes them no better: none, unreadable, or of another frame
/// count than <paramref name="frameCount"/>, the sidecar's. A pass overtaken by an upload, or by another process
/// sharing the archive, would otherwise replace the report a later pass made of the frames as they are, and the next
/// light analysis would drop that one's deep status.
/// whether it saved it. The report replaces the saved one when it describes the frames as they are
/// (<paramref name="current"/>), or when the saved one describes them no better: none, unreadable, or not describing
/// <paramref name="now"/> (the frames as this host reads them, proxies included), or, when they were not read, of
/// another frame count than <paramref name="frameCount"/>, the sidecar's. A pass overtaken by an upload, by a proxy,
/// or by another process sharing the archive, would otherwise replace the report a later pass made of the frames as
/// they are, and the next light analysis would drop that one's deep status.
/// </summary>
private static bool SaveReport(SequencePaths folder, DeepAnalysisReport report, bool current, int frameCount)
private static bool SaveReport(SequencePaths folder, DeepAnalysisReport report, bool current, SequenceFrames? now, int frameCount)
{
var save = current || ReadReport(folder, frameCount) is null;
var save = current || (now is not null ? ReadReport(folder, now) : ReadReport(folder, frameCount)) is null;
if (save) report.Save(folder.AnalysisPath);
Checkpoint(folder).Delete();
return save;