mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix accidental deadlock on NexusApi.Validate(), add extra validation logging
This commit is contained in:
parent
6dde81ec7c
commit
e99a81c34a
@ -148,8 +148,9 @@ public class DownloadDispatcher
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (HttpException)
|
||||
catch (HttpException ex)
|
||||
{
|
||||
_logger.LogError($"Failed verifying {a.State.PrimaryKeyString}: {ex}");
|
||||
await _verificationCache.Put(a.State, false);
|
||||
return false;
|
||||
}
|
||||
|
@ -217,8 +217,9 @@ public class NexusDownloader : ADownloader<Nexus>, IUrlDownloader
|
||||
|
||||
return fileInfo.info.FileId == state.FileID;
|
||||
}
|
||||
catch (HttpException)
|
||||
catch (HttpException ex)
|
||||
{
|
||||
_logger.LogError($"HttpException: {ex} on {archive.Name}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ public class NexusApi
|
||||
public virtual async Task<(ValidateInfo info, ResponseMetadata header)> Validate(
|
||||
CancellationToken token = default)
|
||||
{
|
||||
using var _ = await _authLock.WaitAsync();
|
||||
var (isApi, code) = await GetAuthInfo();
|
||||
|
||||
if (isApi)
|
||||
@ -189,7 +188,6 @@ public class NexusApi
|
||||
protected virtual async ValueTask<HttpRequestMessage> GenerateMessage(HttpMethod method, string uri,
|
||||
params object?[] parameters)
|
||||
{
|
||||
using var _ = await _authLock.WaitAsync();
|
||||
var msg = new HttpRequestMessage();
|
||||
msg.Method = method;
|
||||
|
||||
@ -233,6 +231,7 @@ public class NexusApi
|
||||
|
||||
private async ValueTask<(bool IsApiKey, string code)> GetAuthInfo()
|
||||
{
|
||||
using var _ = await _authLock.WaitAsync();
|
||||
if (AuthInfo.HaveToken())
|
||||
{
|
||||
var info = await AuthInfo.Get();
|
||||
@ -273,6 +272,8 @@ public class NexusApi
|
||||
var response = await _client.PostAsync($"https://users.nexusmods.com/oauth/token", content, cancel);
|
||||
var responseString = await response.Content.ReadAsStringAsync(cancel);
|
||||
var newJwt = JsonSerializer.Deserialize<JwtTokenReply>(responseString);
|
||||
if (newJwt != null)
|
||||
newJwt.ReceivedAt = DateTime.UtcNow.ToFileTimeUtc();
|
||||
|
||||
state.OAuth = newJwt;
|
||||
await AuthInfo.SetToken(state);
|
||||
|
Loading…
Reference in New Issue
Block a user