Skip to content

Commit

Permalink
#### Version - 2.5.3.21 - 6/9/2022
Browse files Browse the repository at this point in the history
* Fix a bug in the streaming MediaFire downloader
* Improve the reliability of MediaFire, and Manual downloaders
* Improve logging around the Wabbajack CDN
  • Loading branch information
halgari committed Jun 9, 2022
1 parent 2ea33bc commit 440de5e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion Wabbajack.Downloaders.MediaFire/MediaFireDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public override async Task<bool> 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") &&
Expand Down
27 changes: 26 additions & 1 deletion Wabbajack.Downloaders.ModDB/ModDBDownloader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
Expand All @@ -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<DTOs.DownloadStates.ModDB>, IUrlDownloader
public class ModDBDownloader : ADownloader<DTOs.DownloadStates.ModDB>, IUrlDownloader, IProxyable
{
private readonly IHttpDownloader _downloader;
private readonly HttpClient _httpClient;
Expand Down Expand Up @@ -70,6 +72,29 @@ public Uri UnParse(IDownloadState state)
return ((DTOs.DownloadStates.ModDB) state).Url;
}

public async Task<T> DownloadStream<T>(Archive archive, Func<Stream, Task<T>> 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<Hash> Download(Archive archive, DTOs.DownloadStates.ModDB state,
AbsolutePath destination, IJob job, CancellationToken token)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ItemGroup>
<ProjectReference Include="..\Wabbajack.Downloaders.Interfaces\Wabbajack.Downloaders.Interfaces.csproj" />
<ProjectReference Include="..\Wabbajack.Networking.Http.Interfaces\Wabbajack.Networking.Http.Interfaces.csproj" />
<ProjectReference Include="..\Wabbajack.Networking.Http\Wabbajack.Networking.Http.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 440de5e

Please sign in to comment.