Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix-downloader-issues' into pre-…
Browse files Browse the repository at this point in the history
…release
  • Loading branch information
EzioTheDeadPoet committed Oct 21, 2023
2 parents d562afc + 2404a85 commit 40ccbe7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Wabbajack.App.Wpf/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public MainWindow(ILogger<MainWindow> logger, SystemParametersConstructor system

Closed += (s, e) =>
{
_logger.LogInformation("Beginning shutdown...");
_mwvm.CancelRunningTasks(TimeSpan.FromSeconds(10));
Application.Current.Shutdown();
};
Expand Down
6 changes: 5 additions & 1 deletion Wabbajack.Common/HttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 11 additions & 2 deletions Wabbajack.Networking.Http/ResumableDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,17 @@ private void DeletePackage()
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)
Expand Down

0 comments on commit 40ccbe7

Please sign in to comment.