fix(archive): the orphans fix clears what covered the frames and queues their analysis
The Archive screen's orphans fix indexed photos copied in by hand but left AnalyzedLight, ThumbsBuilt and ProxiesBuilt set and recorded the folder's stamps, so no scan came back to it and the light analysis was never redone: Auto values, warnings and preview-only tiers stayed those of the old frames. It now clears the three flags in the sidecar and the row as a scan's reconcile does, and queues the light analysis on the host's engine (on a server, the thumbnails and proxies too). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
5 files changed
+124
-17
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using Titano.Core.Archiving;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data.Archiving;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Testing;
|
||||
using static Titano.Data.Tests.Archiving.ArchiveFixture;
|
||||
|
||||
@@ -112,7 +113,7 @@ public sealed class ArchiveIntegrityTests(TestContext context)
|
||||
Assert.Equal(manifest.Frames[0].Id, orphans.MissingFiles.Single().Id);
|
||||
Assert.SequenceEqual(["New folder"], report.UnindexedFolders);
|
||||
|
||||
await fx.Service.ReconcileAsync(id, fx.Ct);
|
||||
await fx.Service.ReconcileAsync(id, null, fx.Ct);
|
||||
var frames = await fx.Db.Frames.ListBySequenceAsync(id);
|
||||
Assert.Equal(4, frames.Count);
|
||||
Assert.Equal(FrameFlags.Missing, frames[0].Flags);
|
||||
@@ -120,6 +121,37 @@ public sealed class ArchiveIntegrityTests(TestContext context)
|
||||
Assert.Empty((await fx.Service.FindOrphansAsync(fx.Archive.Id, fx.Ct)).Sequences.Where(s => s.UnindexedFiles.Count > 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheOrphansFixOnAServerDrawsTheFramesItIndexes()
|
||||
{
|
||||
await using var fx = await CreateAsync(context);
|
||||
var id = await IngestSeriesAsync(fx, "a", 3, 1);
|
||||
// The archive's server, which draws what its clients load; its engine runs no analysis.
|
||||
var server = new ArchiveService(fx.Db, new ArchiveServiceOptions { Owner = "server", LeaseWait = TimeSpan.FromSeconds(20), ImagesAfterScan = true });
|
||||
await using var engine = new JobEngine(fx.Db, server.CreateJobHandlers(),
|
||||
new JobEngineOptions { Workers = 1, WorkerId = "server", PollInterval = TimeSpan.FromMilliseconds(50), CheckpointInterval = TimeSpan.FromMilliseconds(50) });
|
||||
await engine.StartAsync(fx.Ct);
|
||||
foreach (var pass in new[] { ArchiveJobs.Thumbnails([id]), ArchiveJobs.Proxies([id]) })
|
||||
await fx.WaitForAsync((await engine.EnqueueAsync(pass, cancellationToken: fx.Ct)).Id, JobState.Done);
|
||||
var folder = fx.Paths.Sequence((await fx.Db.Sequences.GetAsync(id, fx.Ct))!.Folder);
|
||||
File.WriteAllBytes(Path.Combine(folder.Originals, "dropped.JPG"), Photos.Jpeg(Start.AddMinutes(5), 50));
|
||||
|
||||
// The fix indexes the photo copied in by hand, and queues the thumbnails and proxies of the frames as they are now.
|
||||
var before = (await fx.Db.Jobs.ListAsync(null, null, 100, null, fx.Ct)).Items.Select(j => j.Id).ToHashSet();
|
||||
await server.ReconcileAsync(id, engine, fx.Ct);
|
||||
var queued = (await fx.Db.Jobs.ListAsync(null, null, 100, null, fx.Ct)).Items.Where(j => !before.Contains(j.Id)).ToList();
|
||||
Assert.SequenceEqual([JobKind.Proxies, JobKind.Thumbs], queued.Select(j => j.Kind).Order());
|
||||
foreach (var job in queued)
|
||||
{
|
||||
Assert.SequenceEqual([id], job.TargetIds);
|
||||
await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
}
|
||||
var row = (await fx.Db.Sequences.GetAsync(id, fx.Ct))!;
|
||||
Assert.Equal(4, row.FrameCount);
|
||||
Assert.True(row.Status.HasFlag(SequenceStatus.ThumbsBuilt | SequenceStatus.ProxiesBuilt), row.Status.ToString());
|
||||
Assert.True(File.Exists(folder.Proxy(3)), "proxy of the new frame");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task MaintenanceRemovesOnlyStaleLeftovers()
|
||||
{
|
||||
|
||||
@@ -82,6 +82,42 @@ public sealed class AnalysisFollowUpTests(TestContext context)
|
||||
Assert.True(ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Status.HasFlag(SequenceStatus.AnalyzedLight), "sidecar status");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PhotosTheOrphansFixIndexesAreAnalysedAgain()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(SyntheticSequence.Create(new SyntheticSequenceOptions { FrameCount = 12 }), "Roof");
|
||||
var folder = fx.Folder(sequence);
|
||||
await fx.StartEngineAsync(withArchive: true);
|
||||
var first = await fx.EnqueueAsync(Titano.Data.Processing.ProcessingJobs.LightAnalysis([sequence.Id]));
|
||||
await fx.WaitForAsync(first.Id, JobState.Done);
|
||||
// A server sharing the archive drew the twelve frames and made their proxies.
|
||||
const SequenceStatus images = SequenceStatus.ThumbsBuilt | SequenceStatus.ProxiesBuilt;
|
||||
var manifest = ManifestStore.ReadSequence(folder.ManifestPath);
|
||||
ManifestStore.WriteSequence(folder.ManifestPath, manifest with { Status = manifest.Status | images });
|
||||
await fx.Db.Sequences.UpdateStatusAsync(sequence.Id, images, SequenceStatus.None, fx.Ct);
|
||||
|
||||
// Photos copied into the folder by hand: the Archive screen's orphans check lists them, and its fix indexes them. The
|
||||
// light analysis it queues waits on the first new photo's probe, so what the fix left can be seen.
|
||||
fx.Write(SyntheticSequence.Create(new SyntheticSequenceOptions { FrameCount = 18 }), "Roof", first: 12);
|
||||
fx.Decoder.HoldProbeOf(12);
|
||||
await fx.Archive.Service.ReconcileAsync(sequence.Id, fx.Engine, fx.Ct);
|
||||
const SequenceStatus covering = SequenceStatus.AnalyzedLight | images;
|
||||
var row = (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!;
|
||||
Assert.Equal((18, SequenceStatus.None), (row.FrameCount, row.Status & covering));
|
||||
Assert.Equal(SequenceStatus.None, ManifestStore.ReadSequence(folder.ManifestPath).Status & covering);
|
||||
var again = (await fx.Db.Jobs.ListAsync(null, JobKind.LightAnalyse, cancellationToken: fx.Ct)).Items.Single(j => j.Id != first.Id);
|
||||
Assert.SequenceEqual([sequence.Id], again.TargetIds);
|
||||
|
||||
await fx.Decoder.Holding.Task.WaitAsync(TimeSpan.FromSeconds(60), fx.Ct);
|
||||
fx.Decoder.Release();
|
||||
await fx.WaitForAsync(again.Id, JobState.Done);
|
||||
row = (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!;
|
||||
Assert.True(row.Status.HasFlag(SequenceStatus.AnalyzedLight), "analysed again");
|
||||
Assert.True(ManifestStore.ReadSequence(folder.ManifestPath).Status.HasFlag(SequenceStatus.AnalyzedLight), "sidecar status");
|
||||
Assert.Contains("18", ProjectSettings.FromJson(await File.ReadAllTextAsync(folder.ProjectPath, fx.Ct)).Timing.FrameRate.ReasonArgs!);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AScanAskedForDeepAnalysisQueuesItInTheBackgroundForNewSequencesOnly()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user