28 lines
1012 B
C#
28 lines
1012 B
C#
namespace DysonNetwork.Drive.Storage;
|
|
|
|
public class FileReanalysisBackgroundService(FileReanalysisService reanalysisService, ILogger<FileReanalysisBackgroundService> logger, IConfiguration config) : BackgroundService
|
|
{
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
logger.LogInformation("File reanalysis background service started");
|
|
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
{
|
|
try
|
|
{
|
|
await reanalysisService.ProcessNextFileAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "Error during file reanalysis");
|
|
}
|
|
|
|
// Wait configured milliseconds before processing next file
|
|
var delayMs = config.GetValue("FileReanalysis:DelayMs", 10000);
|
|
await Task.Delay(TimeSpan.FromMilliseconds(delayMs), stoppingToken);
|
|
}
|
|
|
|
logger.LogInformation("File reanalysis background service stopped");
|
|
}
|
|
}
|