diff --git a/Wabbajack.Common/Metrics.cs b/Wabbajack.Common/Metrics.cs index 42f9ae69..ea448b6e 100644 --- a/Wabbajack.Common/Metrics.cs +++ b/Wabbajack.Common/Metrics.cs @@ -19,9 +19,21 @@ namespace Wabbajack.Common using var _ = await _creationLock.WaitAsync(); if (!Utils.HaveEncryptedJson(Consts.MetricsKeyHeader)) { - await Utils.MakeRandomKey().ToEcryptedJson(Consts.MetricsKeyHeader); + var key = Utils.MakeRandomKey(); + await key.ToEcryptedJson(Consts.MetricsKeyHeader); + return key; + } + + try + { + return await Utils.FromEncryptedJson(Consts.MetricsKeyHeader); + } + catch (Exception) + { + var key = Utils.MakeRandomKey(); + await key.ToEcryptedJson(Consts.MetricsKeyHeader); + return key; } - return await Utils.FromEncryptedJson(Consts.MetricsKeyHeader); } /// /// This is all we track for metrics, action, and value. The action will be like diff --git a/Wabbajack.Lib/ClientAPI.cs b/Wabbajack.Lib/ClientAPI.cs index b56c7d0f..6e60b660 100644 --- a/Wabbajack.Lib/ClientAPI.cs +++ b/Wabbajack.Lib/ClientAPI.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net; using System.Net.Http; @@ -46,13 +46,10 @@ namespace Wabbajack.Lib public static async Task GetClient() { var client = new Common.Http.Client(); - if (Utils.HaveEncryptedJson(Consts.MetricsKeyHeader)) - client.Headers.Add((Consts.MetricsKeyHeader, await Utils.FromEncryptedJson(Consts.MetricsKeyHeader))); + client.Headers.Add((Consts.MetricsKeyHeader, await Metrics.GetMetricsKey())); return client; } - - public static async Task GetModUpgrade(Archive oldArchive, Archive newArchive, TimeSpan? maxWait = null, TimeSpan? waitBetweenTries = null) { maxWait ??= TimeSpan.FromMinutes(10);