mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 22:17:22 +01:00
make storage size calculation asynchronous and running in parallel
This commit is contained in:
parent
01e36f64ff
commit
549a93654a
11 changed files with 110 additions and 37 deletions
|
|
@ -352,12 +352,17 @@ public sealed class FileCacheManager : IHostedService
|
|||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Starting FileCacheManager");
|
||||
lock (_fileWriteLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Checking for {bakPath}", CsvBakPath);
|
||||
|
||||
if (File.Exists(CsvBakPath))
|
||||
{
|
||||
_logger.LogInformation("{bakPath} found, moving to {csvPath}", CsvBakPath, _csvPath);
|
||||
|
||||
File.Move(CsvBakPath, _csvPath, overwrite: true);
|
||||
}
|
||||
}
|
||||
|
|
@ -378,6 +383,8 @@ public sealed class FileCacheManager : IHostedService
|
|||
|
||||
if (File.Exists(_csvPath))
|
||||
{
|
||||
_logger.LogInformation("{csvPath} found, parsing", _csvPath);
|
||||
|
||||
bool success = false;
|
||||
string[] entries = [];
|
||||
int attempts = 0;
|
||||
|
|
@ -385,6 +392,7 @@ public sealed class FileCacheManager : IHostedService
|
|||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Attempting to read {csvPath}", _csvPath);
|
||||
entries = File.ReadAllLines(_csvPath);
|
||||
success = true;
|
||||
}
|
||||
|
|
@ -401,6 +409,8 @@ public sealed class FileCacheManager : IHostedService
|
|||
_logger.LogWarning("Could not load entries from {path}, continuing with empty file cache", _csvPath);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Found {amount} files in {path}", entries.Length, _csvPath);
|
||||
|
||||
Dictionary<string, bool> processedFiles = new(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
|
|
@ -447,6 +457,8 @@ public sealed class FileCacheManager : IHostedService
|
|||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Started FileCacheManager");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue