mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 15:07:23 +01:00
recalculate all files on cleanup task (wtf metrics discrepancies)
This commit is contained in:
parent
61af3a3da5
commit
7db72c6030
1 changed files with 5 additions and 7 deletions
|
|
@ -30,15 +30,8 @@ public class FileCleanupService : IHostedService
|
|||
{
|
||||
_logger.LogInformation("Cleanup Service started");
|
||||
|
||||
_logger.LogInformation("Calculating initial files");
|
||||
|
||||
_cleanupCts = new();
|
||||
|
||||
DirectoryInfo dir = new(_cacheDir);
|
||||
var allFiles = dir.GetFiles("*", SearchOption.AllDirectories);
|
||||
_metrics.SetGaugeTo(MetricsAPI.GaugeFilesTotalSize, allFiles.Sum(f => f.Length));
|
||||
_metrics.SetGaugeTo(MetricsAPI.GaugeFilesTotal, allFiles.Length);
|
||||
|
||||
_ = CleanUpTask(_cleanupCts.Token);
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
@ -50,6 +43,11 @@ public class FileCleanupService : IHostedService
|
|||
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
DirectoryInfo dir = new(_cacheDir);
|
||||
var allFiles = dir.GetFiles("*", SearchOption.AllDirectories);
|
||||
_metrics.SetGaugeTo(MetricsAPI.GaugeFilesTotalSize, allFiles.Sum(f => f.Length));
|
||||
_metrics.SetGaugeTo(MetricsAPI.GaugeFilesTotal, allFiles.Length);
|
||||
|
||||
using var scope = _services.CreateScope();
|
||||
using var dbContext = scope.ServiceProvider.GetService<MareDbContext>()!;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue