refactor(sync): queue download follow-ups through the job context
Thumbnail and light-analysis jobs after a download now carry the user who started the download and are skipped when this engine cannot run them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
1 file changed
+5
-15
@@ -138,8 +138,8 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
if (sequenceId is { } downloaded && wanted.Count > restored)
|
||||
{
|
||||
var label = local!.DisplayTitle;
|
||||
await EnqueueFollowUpAsync(ArchiveJobs.Thumbnails([downloaded], label), ct).ConfigureAwait(false);
|
||||
await EnqueueFollowUpAsync(ProcessingJobs.LightAnalysis([downloaded], label), ct).ConfigureAwait(false);
|
||||
await EnqueueFollowUpAsync(context, ArchiveJobs.Thumbnails([downloaded], label)).ConfigureAwait(false);
|
||||
await EnqueueFollowUpAsync(context, ProcessingJobs.LightAnalysis([downloaded], label)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,19 +451,9 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
_ => [],
|
||||
};
|
||||
|
||||
/// <summary>Puts a follow-up job in the queue; the engine claims it on its next poll.</summary>
|
||||
private Task EnqueueFollowUpAsync(ArchiveJobRequest request, CancellationToken cancellationToken) =>
|
||||
sync.Database.Jobs.EnqueueAsync(new Job
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Kind = request.Kind,
|
||||
TargetIds = request.Targets,
|
||||
TargetLabel = request.Label,
|
||||
ParametersJson = request.ParametersJson,
|
||||
Priority = request.Priority,
|
||||
State = JobState.Queued,
|
||||
Created = DateTimeOffset.UtcNow,
|
||||
}, cancellationToken);
|
||||
/// <summary>Queues a follow-up on this job's engine for the same user; skipped when the engine has no handler for it.</summary>
|
||||
private static Task<Job?> EnqueueFollowUpAsync(JobContext context, ArchiveJobRequest request) =>
|
||||
context.EnqueueFollowUpAsync(request.Kind, request.Targets, request.Label, request.ParametersJson, request.Priority);
|
||||
|
||||
private static void EnsureSpace(string root, long bytes)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user