Fixed scanning issue. Updated worker.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using JSMR.Application.Enums;
|
||||
using JSMR.Application.Scanning;
|
||||
using JSMR.Infrastructure.Common.Time;
|
||||
using JSMR.Worker.Options;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
|
||||
namespace JSMR.Worker.Services;
|
||||
|
||||
@@ -21,6 +23,10 @@ public sealed class PagedScanRunner(
|
||||
int startPage = options.StartPage
|
||||
?? (await checkpoints.GetLastPageAsync(options.Locale, cancellationToken)).GetValueOrDefault(0) + 1;
|
||||
|
||||
ITimeProvider timeProvider = serviceProvider.GetRequiredService<ITimeProvider>();
|
||||
|
||||
log.LogInformation("Scanning on {ScanTime}...", timeProvider.Now().DateTime.ToString(CultureInfo.CurrentCulture));
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
int currentPage = startPage;
|
||||
@@ -29,7 +35,8 @@ public sealed class PagedScanRunner(
|
||||
// Iterate until empty page or end reached
|
||||
for (; !cancellationToken.IsCancellationRequested && (!end.HasValue || currentPage <= end.Value); currentPage++)
|
||||
{
|
||||
ScanVoiceWorksHandler handler = serviceProvider.GetRequiredService<ScanVoiceWorksHandler>();
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
ScanVoiceWorksHandler handler = scope.ServiceProvider.GetRequiredService<ScanVoiceWorksHandler>();
|
||||
|
||||
log.LogInformation("Scanning page {Page} (size {Size}, locale {Locale})…", currentPage, pageSize, locale);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user