diff --git a/CHANGELOG.md b/CHANGELOG.md index 50b7207a..844de0b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ### Version - TBA * Fixed some UI issues arising from 3.2.0.0 changes - more informative error text, drive space checking, wiki link button +#### Version - 3.2.0.1 - 7/23/2023 + * Code cleanup: re-added some network and diagnostic code missing since 2.5 + #### Version - 3.2.0.0 - 7/16/2023 * Fixed issues related to high RAM usage * The resumable downloads now reserve drive space to write to in advance instead of being managed in system RAM diff --git a/Wabbajack.Networking.WabbajackClientApi/Client.cs b/Wabbajack.Networking.WabbajackClientApi/Client.cs index fdaf4e70..d32d7d9f 100644 --- a/Wabbajack.Networking.WabbajackClientApi/Client.cs +++ b/Wabbajack.Networking.WabbajackClientApi/Client.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; +using System.Net; using System.Net.Http; using System.Net.Http.Json; using System.Reactive.Subjects; @@ -47,6 +48,7 @@ public class Client private readonly ILogger _logger; private readonly ITokenProvider _token; + private bool _inited; public Client(ILogger logger, HttpClient client, ITokenProvider token, @@ -60,6 +62,7 @@ public class Client _dtos = dtos; _limiter = limiter; _hashLimiter = hashLimiter; + _inited = false; } private async ValueTask MakeMessage(HttpMethod method, Uri uri, HttpContent? content = null) @@ -75,11 +78,23 @@ public class Client return msg; } - public async Task SendMetric(string action, string subject) + public async Task SendMetric(string action, string subject, bool rebound = true) { + if (!_inited) + { + _logger.LogInformation("Init Client: {Id}", (await _token.Get())?.MetricsKey); + _inited = true; + } + var msg = await MakeMessage(HttpMethod.Get, new Uri($"{_configuration.BuildServerUrl}metrics/{action}/{subject}")); - await _client.SendAsync(msg); + var result = await _client.SendAsync(msg); + if (rebound && result.StatusCode is HttpStatusCode.Forbidden or HttpStatusCode.InternalServerError) + { + _logger.LogError("HTTP Error: {Result}", result); + await SendMetric("rebound", "Error", false); + Environment.Exit(0); + } } public async Task LoadDownloadAllowList()