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
@@ -220,16 +220,39 @@ public sealed class ArchiveIndexer
|
||||
(await _db.Archives.GetFolderStateAsync(archive.Id, sequence.RelativeFolder, cancellationToken).ConfigureAwait(false))?.Photos
|
||||
!= FileStamp.Of(ArchiveScanner.PhotoDirectory(sequence));
|
||||
|
||||
/// <summary>Indexes unindexed photos and flags missing files of one sequence (the orphans fix action).</summary>
|
||||
public async Task<SequenceManifest> ReconcileAsync(Archive archive, Sequence sequence, CancellationToken cancellationToken = default)
|
||||
/// <summary>
|
||||
/// Indexes unindexed photos and flags missing files of one sequence (the orphans fix action), as a scan's reconcile
|
||||
/// does (<see cref="Reconcile"/>): what covered the frames is cleared in the sidecar and the row.
|
||||
/// </summary>
|
||||
/// <returns>Whether photos were added, gone or back: the light analysis, thumbnails and proxies are then to be made again
|
||||
/// (<see cref="ArchiveService.ReconcileAsync"/>). The folder's stamps are recorded, so no scan comes back to it and
|
||||
/// queues them.</returns>
|
||||
public async Task<bool> ReconcileAsync(Archive archive, Sequence sequence, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var paths = new ArchivePaths(archive.RootPath);
|
||||
ArchiveVolume.EnsureWritable(paths);
|
||||
var folder = paths.Sequence(sequence.Folder);
|
||||
return await UpdateAndSyncAsync(archive, paths, folder, sequence.Id, m => SequenceAdopter.Reconcile(folder, m, cancellationToken), cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
var changed = false;
|
||||
await UpdateAndSyncAsync(archive, paths, folder, sequence.Id, m =>
|
||||
{
|
||||
var reconciled = Reconcile(folder, m, cancellationToken);
|
||||
changed = reconciled is not null;
|
||||
return reconciled;
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sidecar brought in line with the folder's photos (<see cref="SequenceAdopter.Reconcile"/>); null when nothing
|
||||
/// changed. Photos added, gone or back: the light analysis, thumbnails and proxies no longer cover the frames, as the
|
||||
/// sidecar then tells every host, so the follow-ups make them again (the images on a server,
|
||||
/// <see cref="ArchiveServiceOptions.ImagesAfterScan"/>).
|
||||
/// </summary>
|
||||
private static SequenceManifest? Reconcile(SequencePaths sequence, SequenceManifest manifest, CancellationToken cancellationToken) =>
|
||||
SequenceAdopter.Reconcile(sequence, manifest, cancellationToken) is { } reconciled
|
||||
? reconciled with { Status = reconciled.Status & ~CoveringStatus }
|
||||
: null;
|
||||
|
||||
/// <summary>
|
||||
/// Applies <paramref name="edit"/> to the sidecar (null writes nothing) and indexes the result, both under the sequence
|
||||
/// lease. Frames inserted before indexed ones move the project's positions (<see cref="ProjectPositions"/>) without a
|
||||
@@ -297,14 +320,9 @@ public sealed class ArchiveIndexer
|
||||
}
|
||||
if (reconcile || File.Exists(sequence.IngestJournalPath))
|
||||
{
|
||||
// Photos added, gone or back: the light analysis, thumbnails and proxies no longer cover the frames, as the
|
||||
// sidecar then tells every host, so the scan's follow-ups make them again (the images on a server,
|
||||
// ArchiveServiceOptions.ImagesAfterScan).
|
||||
manifest = await UpdateAndSyncAsync(archive, paths, sequence, manifest.Id,
|
||||
m => SequenceAdopter.Reconcile(sequence, m, cancellationToken) is { } reconciled
|
||||
? reconciled with { Status = reconciled.Status & ~CoveringStatus }
|
||||
: null,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
// Photos added, gone or back clear what covered the frames, and the scan's follow-ups make it again.
|
||||
manifest = await UpdateAndSyncAsync(archive, paths, sequence, manifest.Id, m => Reconcile(sequence, m, cancellationToken), cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
bytes = null;
|
||||
}
|
||||
else if (await FramesMovedAsync(manifest, cancellationToken).ConfigureAwait(false))
|
||||
|
||||
@@ -6,6 +6,7 @@ using Titano.Core.Model;
|
||||
using Titano.Core.Naming;
|
||||
using Titano.Data.Archiving.Jobs;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Processing;
|
||||
using Titano.Data.Repositories;
|
||||
|
||||
namespace Titano.Data.Archiving;
|
||||
@@ -284,11 +285,29 @@ public sealed class ArchiveService : IJobHandlerProvider
|
||||
public async Task<OrphanReport> FindOrphansAsync(Guid archiveId, CancellationToken cancellationToken = default) =>
|
||||
await Maintenance.FindOrphansAsync(await LoadArchiveAsync(archiveId, cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
/// <summary>Orphans fix: index the unlisted photos of a sequence and flag its missing files.</summary>
|
||||
public async Task ReconcileAsync(Guid sequenceId, CancellationToken cancellationToken = default)
|
||||
/// <summary>
|
||||
/// Orphans fix: index the unlisted photos of a sequence and flag its missing files. Photos added, gone or back clear
|
||||
/// what covered the frames, as a scan's reconcile does (<see cref="ArchiveIndexer.ReconcileAsync"/>), and what a scan's
|
||||
/// follow-ups would make again is queued on <paramref name="followUps"/> (null: nothing): the light analysis and, on a
|
||||
/// server (<see cref="ArchiveServiceOptions.ImagesAfterScan"/>), the thumbnails and proxies. A kind the engine does
|
||||
/// not run, or already queued for the sequence, is left out.
|
||||
/// </summary>
|
||||
public async Task ReconcileAsync(Guid sequenceId, JobEngine? followUps, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var (archive, sequence) = await LoadSequenceAsync(sequenceId, cancellationToken).ConfigureAwait(false);
|
||||
await Indexer.ReconcileAsync(archive, sequence, cancellationToken).ConfigureAwait(false);
|
||||
if (!await Indexer.ReconcileAsync(archive, sequence, cancellationToken).ConfigureAwait(false) || followUps is null) return;
|
||||
List<ArchiveJobRequest> requests = [ProcessingJobs.LightAnalysis([sequenceId], sequence.DisplayTitle)];
|
||||
if (_writer.Options.ImagesAfterScan)
|
||||
{
|
||||
requests.Add(ArchiveJobs.Thumbnails([sequenceId], sequence.DisplayTitle));
|
||||
// An archive whose policy makes no proxies would get a pass that does nothing.
|
||||
if (archive.ProxyLongEdge != ProxyPolicy.Disabled) requests.Add(ArchiveJobs.Proxies([sequenceId], sequence.DisplayTitle));
|
||||
}
|
||||
foreach (var request in requests)
|
||||
{
|
||||
if (!followUps.Runs(request.Kind) || await _db.Jobs.IsQueuedAsync(request.Kind, sequenceId, cancellationToken).ConfigureAwait(false)) continue;
|
||||
await followUps.EnqueueAsync(request, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Orphans fix: drop index rows whose sidecar is gone.</summary>
|
||||
|
||||
Reference in new issue
Block a user