diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2ee1164..4cb691367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ### Changelog +#### Version - 2.5.3.21 - 6/9/2022 +* Fix a bug in the streaming MediaFire downloader +* Improve the reliability of MediaFire, and Manual downloaders +* Improve logging around the Wabbajack CDN + #### Version - 2.5.3.20 - 6/8/2022 * Improve reliability of MediaFire, Mega and GDrive downloaders diff --git a/Wabbajack.Downloaders.MediaFire/MediaFireDownloader.cs b/Wabbajack.Downloaders.MediaFire/MediaFireDownloader.cs index abd16ab2a..2f6d25e5d 100644 --- a/Wabbajack.Downloaders.MediaFire/MediaFireDownloader.cs +++ b/Wabbajack.Downloaders.MediaFire/MediaFireDownloader.cs @@ -111,7 +111,8 @@ public override async Task Verify(Archive archive, DTOs.DownloadStates.Med StringComparison.OrdinalIgnoreCase)) { var bodyData = await result.Content.ReadAsStringAsync((CancellationToken) token); - await job.Report((int) job.Size, (CancellationToken) token); + if (job != null) + await job.Report((int) job.Size, (CancellationToken) token); var body = new HtmlDocument(); body.LoadHtml(bodyData); var node = body.DocumentNode.DescendantsAndSelf().First(d => d.HasClass("input") && d.HasClass("popsok") && diff --git a/Wabbajack.Downloaders.ModDB/ModDBDownloader.cs b/Wabbajack.Downloaders.ModDB/ModDBDownloader.cs index 157f66725..70399256b 100644 --- a/Wabbajack.Downloaders.ModDB/ModDBDownloader.cs +++ b/Wabbajack.Downloaders.ModDB/ModDBDownloader.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net.Http; using System.Threading; @@ -11,13 +12,14 @@ using Wabbajack.DTOs.DownloadStates; using Wabbajack.DTOs.Validation; using Wabbajack.Hashing.xxHash64; +using Wabbajack.Networking.Http; using Wabbajack.Networking.Http.Interfaces; using Wabbajack.Paths; using Wabbajack.RateLimiter; namespace Wabbajack.Downloaders.ModDB; -public class ModDBDownloader : ADownloader, IUrlDownloader +public class ModDBDownloader : ADownloader, IUrlDownloader, IProxyable { private readonly IHttpDownloader _downloader; private readonly HttpClient _httpClient; @@ -70,6 +72,29 @@ public Uri UnParse(IDownloadState state) return ((DTOs.DownloadStates.ModDB) state).Url; } + public async Task DownloadStream(Archive archive, Func> fn, CancellationToken token) + { + var state = archive.State as DTOs.DownloadStates.ModDB; + var url = (await GetDownloadUrls(state!)).First(); + try + { + var msg = new HttpRequestMessage + { + Method = HttpMethod.Get, + RequestUri = new Uri(url) + }; + using var response = await _httpClient.SendAsync(msg, token); + HttpException.ThrowOnFailure(response); + await using var stream = await response.Content.ReadAsStreamAsync(token); + return await fn(stream); + } + catch (Exception ex) + { + _logger.LogError(ex, "While downloading from ModDB"); + throw; + } + } + public override async Task Download(Archive archive, DTOs.DownloadStates.ModDB state, AbsolutePath destination, IJob job, CancellationToken token) { diff --git a/Wabbajack.Downloaders.ModDB/Wabbajack.Downloaders.ModDB.csproj b/Wabbajack.Downloaders.ModDB/Wabbajack.Downloaders.ModDB.csproj index edd634488..8faa94480 100644 --- a/Wabbajack.Downloaders.ModDB/Wabbajack.Downloaders.ModDB.csproj +++ b/Wabbajack.Downloaders.ModDB/Wabbajack.Downloaders.ModDB.csproj @@ -8,6 +8,7 @@ +