diff --git a/src/Titano.Data/Sync/SyncTransfers.cs b/src/Titano.Data/Sync/SyncTransfers.cs index 3fb1fa6b..5f0f356d 100644 --- a/src/Titano.Data/Sync/SyncTransfers.cs +++ b/src/Titano.Data/Sync/SyncTransfers.cs @@ -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) _ => [], }; - /// Puts a follow-up job in the queue; the engine claims it on its next poll. - 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); + /// Queues a follow-up on this job's engine for the same user; skipped when the engine has no handler for it. + private static Task 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) {