try catch on cleanup task
This commit is contained in:
@@ -44,6 +44,8 @@ public class FileCleanupService : IHostedService
|
||||
_logger.LogInformation("Starting periodic cleanup task");
|
||||
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
DirectoryInfo dir = new(_cacheDir);
|
||||
var allFiles = dir.GetFiles("*", SearchOption.AllDirectories);
|
||||
@@ -63,6 +65,11 @@ public class FileCleanupService : IHostedService
|
||||
|
||||
await dbContext.SaveChangesAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Error during cleanup task");
|
||||
}
|
||||
|
||||
var now = DateTime.Now;
|
||||
TimeOnly currentTime = new(now.Hour, now.Minute, now.Second);
|
||||
|
||||
Reference in New Issue
Block a user