diff options
Diffstat (limited to 'Services/OcrService.cs')
| -rw-r--r-- | Services/OcrService.cs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Services/OcrService.cs b/Services/OcrService.cs index 4d21705..40905aa 100644 --- a/Services/OcrService.cs +++ b/Services/OcrService.cs @@ -18,18 +18,21 @@ public class OcrService : IHostedService { private Timer timer; + private IConfigService configService; private IServiceScopeFactory scopeFactory; private ILogger<OcrService> logger; private IDbContextFactory<HBContext> dbFactory; public OcrService( + IConfigService configService, IServiceScopeFactory scopeFactory, ILogger<OcrService> logger, IDbContextFactory<HBContext> dbFactory) { - this.scopeFactory = scopeFactory; - this.logger = logger; - this.dbFactory = dbFactory; + this.configService = configService; + this.scopeFactory = scopeFactory; + this.logger = logger; + this.dbFactory = dbFactory; timer = new((object? state) => { if(task is not null && !task.IsCompleted) @@ -40,8 +43,11 @@ public class OcrService : IHostedService { } public Task StartAsync(CancellationToken ct) { - logger.LogInformation("Service starting..."); - timer.Change(StartupDelay, ProcessInterval); + if(configService.EnableOcr) { + logger.LogInformation("Service starting..."); + timer.Change(StartupDelay, ProcessInterval); + } + return Task.CompletedTask; } @@ -53,8 +59,6 @@ public class OcrService : IHostedService { } async Task ProcessAllAsync(CancellationToken ct) { - return; - using var scope = scopeFactory.CreateScope(); var mediaService = scope.ServiceProvider .GetRequiredService<IMediaService>(); |
