some fixes maybe

This commit is contained in:
rootdarkarchon
2024-02-22 12:36:37 +01:00
committed by Loporrit
parent 9d9573a510
commit 9b9f6cd2f9
2 changed files with 12 additions and 4 deletions

View File

@@ -83,6 +83,7 @@ public class ShardFileCleanupService : IHostedService
{
_logger.LogInformation("Cleaning up files beyond the cache size limit of {cacheSizeLimit} GiB", sizeLimit);
var allLocalFiles = Directory.EnumerateFiles(_cacheDir, "*", SearchOption.AllDirectories)
.Where(f => !f.EndsWith("dl", StringComparison.OrdinalIgnoreCase))
.Select(f => new FileInfo(f)).ToList()
.OrderBy(f => f.LastAccessTimeUtc).ToList();
var totalCacheSizeInBytes = allLocalFiles.Sum(s => s.Length);
@@ -120,7 +121,9 @@ public class ShardFileCleanupService : IHostedService
var prevTime = DateTime.Now.Subtract(TimeSpan.FromDays(unusedRetention));
var prevTimeForcedDeletion = DateTime.Now.Subtract(TimeSpan.FromHours(forcedDeletionAfterHours));
DirectoryInfo dir = new(_cacheDir);
var allFilesInDir = dir.GetFiles("*", SearchOption.AllDirectories);
var allFilesInDir = dir.GetFiles("*", SearchOption.AllDirectories)
.Where(f => !f.Name.EndsWith("dl", StringComparison.OrdinalIgnoreCase))
.ToList();
foreach (var file in allFilesInDir)
{