Catch exceptions in expired deletion service

This commit is contained in:
Kieran 2023-04-09 14:26:51 +01:00
parent de975be92f
commit 1c370dfd24
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -21,6 +21,8 @@ public sealed class DeleteExpiredFiles : BackgroundService
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
try
{
using var scope = _scopeFactory.CreateScope();
var metadata = scope.ServiceProvider.GetRequiredService<IFileMetadataStore>();
@ -46,6 +48,12 @@ public sealed class DeleteExpiredFiles : BackgroundService
}
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to run delete expired file services");
}
await Task.Delay(TimeSpan.FromMinutes(5), stoppingToken);
}
}