Merge remote-tracking branch 'origin/master'

This commit is contained in:
Timothy Baldridge 2021-01-12 15:47:52 -07:00
commit 4a555c27b9
4 changed files with 39 additions and 5 deletions

View File

@ -11,6 +11,7 @@ using Wabbajack.Common.Exceptions;
using Wabbajack.Common.Serialization.Json;
using Wabbajack.Lib.AuthorApi;
using Wabbajack.Lib.Validation;
using System.Linq;
namespace Wabbajack.Lib.Downloaders
{
@ -89,7 +90,7 @@ namespace Wabbajack.Lib.Downloaders
if (DomainRemaps.TryGetValue(Url.Host, out var remap))
{
var builder = new UriBuilder(Url) {Host = remap};
using var response = await client.GetAsync($"{builder}/parts/{part.Index}");
using var response = await GetWithCDNRetry(client, $"{builder}/parts/{part.Index}");
if (!response.IsSuccessStatusCode)
throw new HttpException((int)response.StatusCode, response.ReasonPhrase ?? "Unknown");
await response.Content.CopyToAsync(ostream);
@ -114,6 +115,31 @@ namespace Wabbajack.Lib.Downloaders
return true;
}
private async Task<HttpResponseMessage> GetWithCDNRetry(Http.Client client, string url, CancellationToken? token = null)
{
int retries = 0;
TOP:
try
{
return await client.GetAsync(url, retry: false, token: token);
}
catch (Exception ex)
{
if (retries > 2)
{
Utils.Log($"Trying CDN...");
var remap = url.Replace(new Uri(url).Host, DomainRemaps.FirstOrDefault(x => x.Value == new Uri(url).Host).Key);
return await client.GetAsync(remap, retry: false, token: token);
}
retries += 1;
Utils.Log($"Error reading {url} retrying [{retries}]");
Utils.Log(ex.ToString());
goto TOP;
}
}
private async Task<HttpResponseMessage> GetWithMirroredRetry(Http.Client client, string url)
{
int retries = 0;
@ -157,7 +183,7 @@ namespace Wabbajack.Lib.Downloaders
if (DomainRemaps.TryGetValue(Url.Host, out var remap))
{
var builder = new UriBuilder(Url) {Host = remap};
using var data = await client.GetAsync(builder + "/definition.json.gz", token: token);
using var data = await GetWithCDNRetry(client, builder + "/definition.json.gz", token: token);
await using var gz = new GZipStream(await data.Content.ReadAsStreamAsync(),
CompressionMode.Decompress);
return gz.FromJson<CDNFileDefinition>();

View File

@ -15,6 +15,8 @@ namespace Wabbajack.Lib
public long VideoMemorySize { get; set; }
public long SystemMemorySize { get; set; }
public long SystemPageSize { get; set; }
public Version WindowsVersion { get; set; } = Environment.OSVersion.Version;
/// <summary>

View File

@ -56,6 +56,7 @@ namespace Wabbajack.Util
ScreenHeight = height,
VideoMemorySize = video_memory,
SystemMemorySize = (long)memory.ullTotalPhys,
SystemPageSize = (long)memory.ullTotalPageFile - (long)memory.ullTotalPhys
};
}
}

View File

@ -42,12 +42,17 @@ namespace Wabbajack
Utils.Log($"Detected Windows Version: {p.WindowsVersion}");
if (!(p.WindowsVersion.Major >= 6 && p.WindowsVersion.Minor >= 2))
if (!(p.WindowsVersion.Major >= 10 && p.WindowsVersion.Minor >= 0))
Utils.Log(
$"You are not running a recent version of Windows (version 10 or greater), Wabbajack is not supported on OS versions older than Windows 10.");
Utils.Log(
$"System settings - ({p.SystemMemorySize.ToFileSizeString()} RAM), Display: {p.ScreenWidth} x {p.ScreenHeight} ({p.VideoMemorySize.ToFileSizeString()} VRAM - VideoMemorySizeMb={p.EnbLEVRAMSize})");
$"System settings - ({p.SystemMemorySize.ToFileSizeString()} RAM) ({p.SystemPageSize.ToFileSizeString()} Page), Display: {p.ScreenWidth} x {p.ScreenHeight} ({p.VideoMemorySize.ToFileSizeString()} VRAM - VideoMemorySizeMb={p.EnbLEVRAMSize})");
if (p.SystemPageSize == 0)
Utils.Log("Pagefile is disabled! Consider increasing to 20000MB. A disabled pagefile can cause crashes and poor in-game performance.");
else if (p.SystemPageSize < 2e+10)
Utils.Log("Pagefile below recommended! Consider increasing to 20000MB. A suboptimal pagefile can cause crashes and poor in-game performance.");
Warmup();
@ -83,7 +88,7 @@ namespace Wabbajack
catch (Exception ex)
{
Utils.LogStraightToFile("Error");
Utils.LogStraightToFile(ex.ToString());
Utils.LogStraightToFile(ex.ToString());
Environment.Exit(-1);
}
}