Merge remote-tracking branch 'origin/fix-downloader-issues' into pre-release

This commit is contained in:
EzioTheDeadPoet 2023-10-21 18:13:07 +02:00
commit 40ccbe761c
3 changed files with 17 additions and 3 deletions

View File

@ -45,6 +45,7 @@ namespace Wabbajack
Closed += (s, e) =>
{
_logger.LogInformation("Beginning shutdown...");
_mwvm.CancelRunningTasks(TimeSpan.FromSeconds(10));
Application.Current.Shutdown();
};

View File

@ -18,7 +18,11 @@ public static class HttpExtensions
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36";
public static HttpRequestMessage AddCookies(this HttpRequestMessage msg, Cookie[] cookies)
{
msg.Headers.Add("Cookie", string.Join(";", cookies.Select(c => $"{c.Name}={c.Value}")));
if (cookies.Length > 0)
{
msg.Headers.Add("Cookie", string.Join(";", cookies.Select(c => $"{c.Name}={c.Value}")));
}
return msg;
}

View File

@ -166,8 +166,17 @@ internal class ResumableDownloader
return null;
}
var packageJson = _packagePath.ReadAllText();
return JsonSerializer.Deserialize<DownloadPackage>(packageJson);
try
{
var packageJson = _packagePath.ReadAllText();
return JsonSerializer.Deserialize<DownloadPackage>(packageJson);
}
catch (JsonException ex)
{
_logger.LogWarning(ex, "Package for '{name}' couldn't be parsed. Deleting package and starting from scratch...", _outputPath.FileName.ToString());
DeletePackage();
return null;
}
}
private void SavePackage(DownloadPackage package)