Files
Swarm/DysonNetwork.Drive/Storage/FileReanalysisBackgroundService.cs
2026-01-14 19:09:10 +08:00

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");
}
}