mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 20:27:22 +01:00
try catch on cleanup task
This commit is contained in:
parent
91b98d060a
commit
6560b1d70d
1 changed files with 22 additions and 15 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue