Skip to content

Commit

Permalink
3.2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Jul 24, 2023
1 parent 4017c5c commit 77f6b8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### Changelog

#### 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
Expand Down
19 changes: 17 additions & 2 deletions Wabbajack.Networking.WabbajackClientApi/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class Client
private readonly ILogger<Client> _logger;

private readonly ITokenProvider<WabbajackApiState> _token;
private bool _inited;


public Client(ILogger<Client> logger, HttpClient client, ITokenProvider<WabbajackApiState> token,
Expand All @@ -60,6 +62,7 @@ public Client(ILogger<Client> logger, HttpClient client, ITokenProvider<Wabbajac
_dtos = dtos;
_limiter = limiter;
_hashLimiter = hashLimiter;
_inited = false;
}

private async ValueTask<HttpRequestMessage> MakeMessage(HttpMethod method, Uri uri, HttpContent? content = null)
Expand All @@ -75,11 +78,23 @@ private async ValueTask<HttpRequestMessage> MakeMessage(HttpMethod method, Uri u
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<ServerAllowList> LoadDownloadAllowList()
Expand Down

0 comments on commit 77f6b8c

Please sign in to comment.