mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 21:27:21 +01:00
delete last 5% of files once storage reaches limit
This commit is contained in:
parent
d5f140a142
commit
2b6a918aea
2 changed files with 6 additions and 3 deletions
|
|
@ -106,11 +106,14 @@ public sealed class PeriodicFileScanner : DisposableMediatorSubscriberBase
|
|||
}
|
||||
});
|
||||
|
||||
if (FileCacheSize < (long)(_configService.Current.MaxLocalCacheInGiB * 1024d * 1024d * 1024d)) return false;
|
||||
var maxCacheInBytes = (long)(_configService.Current.MaxLocalCacheInGiB * 1024d * 1024d * 1024d);
|
||||
|
||||
if (FileCacheSize < maxCacheInBytes) return false;
|
||||
|
||||
var allFiles = Directory.EnumerateFiles(_configService.Current.CacheFolder)
|
||||
.Select(f => new FileInfo(f)).OrderBy(f => f.LastAccessTime).ToList();
|
||||
while (FileCacheSize > (long)(_configService.Current.MaxLocalCacheInGiB * 1024d * 1024d * 1024d))
|
||||
var maxCacheBuffer = maxCacheInBytes * 0.05d;
|
||||
while (FileCacheSize > maxCacheInBytes - (long)maxCacheBuffer)
|
||||
{
|
||||
var oldestFile = allFiles[0];
|
||||
FileCacheSize -= oldestFile.Length;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue