Log tar log loading

This commit is contained in:
Timothy Baldridge 2023-05-02 17:01:12 -06:00
parent b0d3a4315f
commit b66632f930

View File

@ -1,3 +1,4 @@
using Microsoft.Extensions.Logging;
using Wabbajack.BuildServer;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
@ -8,10 +9,12 @@ public class TarLog
{
private Task<HashSet<string>> _tarKeys;
private readonly AppSettings _settings;
private readonly ILogger<TarLog> _logger;
public TarLog(AppSettings settings)
public TarLog(AppSettings settings, ILogger<TarLog> logger)
{
_settings = settings;
_logger = logger;
Load();
}
@ -19,15 +22,21 @@ public class TarLog
{
if (_settings.TarKeyFile.ToAbsolutePath().FileExists())
{
_tarKeys = Task.Run(async () => await _settings.TarKeyFile.ToAbsolutePath()
_tarKeys = Task.Run(async () =>
{
var keys = await _settings.TarKeyFile.ToAbsolutePath()
.ReadAllLinesAsync()
.Select(line => line.Trim())
.ToHashSetAsync());
.ToHashSetAsync();
_logger.LogInformation("Loaded {Count} tar keys", keys.Count);
return keys;
});
}
else
{
_tarKeys = Task.Run(async () => new HashSet<string>());
}
}
public async Task<bool> Contains(string metricsKey)