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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user