feat(jobs): every job handler reports a structured progress detail
The job list showed a bar and a free-text line that each handler worded its own way. Each handler now reports its step, the item it is on, photo x of y and sequence/folder/output/step n of m through the P2.1 JobContext detail. Clients can word and lay that out themselves, and the 2/s throttle keeps the cost low: counts within a step go through ReportItemAsync, which allocates nothing. - scan: List, then Index (folder n of m, photo x of y as an adopted or reconciled folder is read) or Check, then FollowUps - verify, thumbs, proxies, deep analysis: photo x of y of sequence n of m; light analysis: sequence n of m; a thumbnail/proxy checkpoint carries the frame count it saves - convert: Verify (resume), Convert photo x of y, Replace; reorganize: step n of m with the title; import: the file being copied, photo x of y - maintenance: the step key, step n of 5, then Check; duplicates, orphans and backup run with no count; cleanup names step n of m; empty trash: entry n of m - render (local, workspace, render node): Analyse, Encode (frames of the last output, output n of m in a batch), Verify; sync, video copy, workspace copy/send/move: Upload/Download/CopyProxy/CopyOriginal/ CopyVideo/Reorganize with their items and counts The detail carries keys and names only, never localized text. The existing Message strings stay for clients that still show them. Refs #65 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ee9505df22
commit
45e6911082
31 files changed
+759
-119
No files matched your search
@@ -37,16 +37,16 @@ internal sealed class ScanJobHandler(ChronosDatabase db, ArchiveIndexer indexer,
|
||||
var parameters = ArchiveJobJson.Read(context.Job, ArchiveJobJson.Default.ScanParameters, new ScanParameters(false));
|
||||
var mode = kind == JobKind.Rebuild ? ScanMode.Rebuild : parameters.Full ? ScanMode.Full : ScanMode.Incremental;
|
||||
var resume = context.Checkpoint is { } checkpoint && checkpoint.StartsWith(Prefix, StringComparison.Ordinal) ? checkpoint[Prefix.Length..] : null;
|
||||
var summary = await indexer.ScanAsync(archive, mode, resume, async p =>
|
||||
{
|
||||
if (p.Changed) await context.CheckpointAsync(Prefix + p.Folder, p.FoldersDone, p.FoldersTotal).ConfigureAwait(false);
|
||||
else await context.ReportAsync(p.FoldersDone, p.FoldersTotal, p.Folder).ConfigureAwait(false);
|
||||
}, context.Cancellation).ConfigureAwait(false);
|
||||
// Listing the folders reads the whole tree before the first one is counted.
|
||||
await context.ReportAsync(context.Done, context.Total, new JobDetail(JobStep.List)).ConfigureAwait(false);
|
||||
var progress = new ScanReporter(context);
|
||||
var summary = await indexer.ScanAsync(archive, mode, resume, progress.ReportAsync, context.Cancellation).ConfigureAwait(false);
|
||||
foreach (var (folder, error) in summary.Failed) context.Log(Loc.L("Archive.Log.FolderFailed", folder, error));
|
||||
context.Log(Loc.L("Archive.Log.ScanDone", summary.Folders, summary.Indexed, summary.Adopted, summary.Removed));
|
||||
// A resumed scan may have indexed its folders before the interruption.
|
||||
if (summary.Indexed > 0 || resume is not null)
|
||||
{
|
||||
await context.ReportAsync(summary.Folders, summary.Folders, new JobDetail(JobStep.FollowUps)).ConfigureAwait(false);
|
||||
var awaiting = await indexer.AwaitingFolderAsync(new ArchivePaths(archive.RootPath),
|
||||
await db.Sequences.ListLocationsAsync(archive.Id, context.Cancellation).ConfigureAwait(false), context.Cancellation).ConfigureAwait(false);
|
||||
var unanalysed = (await AnalysisFollowUp.UnanalysedAsync(db, archive.Id, context.Cancellation).ConfigureAwait(false))
|
||||
@@ -64,6 +64,30 @@ internal sealed class ScanJobHandler(ChronosDatabase db, ArchiveIndexer indexer,
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The scan's progress as the job's: folders on the bar; folder n of m, checked or indexed, with the photo being read
|
||||
/// in an adopted or reconciled folder, in the detail. A changed folder done is the resume point.
|
||||
/// </summary>
|
||||
private sealed class ScanReporter(JobContext context)
|
||||
{
|
||||
private string? _indexing;
|
||||
|
||||
public ValueTask ReportAsync(ScanProgress p)
|
||||
{
|
||||
if (p.Indexing)
|
||||
{
|
||||
// Photo after photo inside the folder: counts only, the folder's detail stays.
|
||||
if (string.Equals(_indexing, p.Folder, StringComparison.Ordinal)) return context.ReportItemAsync(p.FoldersDone, p.FoldersTotal, p.PhotosDone, p.PhotosTotal);
|
||||
_indexing = p.Folder;
|
||||
return context.ReportAsync(p.FoldersDone, p.FoldersTotal,
|
||||
new JobDetail(JobStep.Index, p.Folder, p.PhotosDone, p.PhotosTotal, p.FoldersDone + 1, p.FoldersTotal, JobPartUnit.Folder));
|
||||
}
|
||||
_indexing = null;
|
||||
if (p.Changed) return context.CheckpointAsync(Prefix + p.Folder, p.FoldersDone, p.FoldersTotal);
|
||||
return context.ReportAsync(p.FoldersDone, p.FoldersTotal, new JobDetail(JobStep.Check, p.Folder, 0, 0, p.FoldersDone, p.FoldersTotal, JobPartUnit.Folder));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues a background <paramref name="pass"/> (thumbnails or proxies) of each sequence this run indexed whose
|
||||
/// <paramref name="built"/> flag is clear: new and adopted sequences, and those whose photos changed (the scan clears the
|
||||
|
||||
Reference in new issue
Block a user