Merge pull request #1244 from wabbajack-tools/small-downloader-fixes

Small downloader fixes
This commit is contained in:
Timothy Baldridge 2021-01-06 16:37:18 -07:00 committed by GitHub
commit ff386d000e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 16 deletions

View File

@ -5,6 +5,8 @@
* Origin is now supported as a game source
* Basic (mostly untested) support for Dragon Age : Origins
* Replace RocksDB with SQLite should result in less process contention when running the UI and the CLI at the same time
* Fixed Regression with CloudFront IPS4 sites not requesting logins before installation
* Fixed regression that caused us to spam the Nexus with verify calls
#### Version - 2.3.6.2 - 12/31/2020
* HOTFIX: Also apply the IPS4 changes to LL Meta lookups

View File

@ -50,8 +50,9 @@ namespace Compression.BSA.Test
private static async Task<AbsolutePath> DownloadMod(Game game, int mod)
{
using var client = await NexusApiClient.Get();
var results = await client.GetModFiles(game, mod);
var client = DownloadDispatcher.GetInstance<NexusDownloader>();
await client.Prepare();
var results = await client.Client!.GetModFiles(game, mod);
var file = results.files.FirstOrDefault(f => f.is_primary) ??
results.files.OrderByDescending(f => f.uploaded_timestamp).First();
var src = _stagingFolder.Combine(file.file_name);

View File

@ -92,7 +92,7 @@ namespace Wabbajack.Lib.Downloaders
public async Task<Http.Client> GetAuthedClient()
{
Helpers.Cookie[] cookies;
if (Consts.IsServer)
if (Consts.IsServer || IsCloudFlareProtected)
{
try
{

View File

@ -66,7 +66,7 @@ namespace Wabbajack.Lib.Downloaders
};
}
var client = await NexusApiClient.Get();
var client = DownloadDispatcher.GetInstance<NexusDownloader>().Client ?? await NexusApiClient.Get();
ModInfo info;
try
{
@ -198,8 +198,7 @@ namespace Wabbajack.Lib.Downloaders
string url;
try
{
var client = await NexusApiClient.Get();
url = await client.GetNexusDownloadLink(this);
url = await DownloadDispatcher.GetInstance<NexusDownloader>().Client!.GetNexusDownloadLink(this);
}
catch (NexusAPIQuotaExceeded ex)
{
@ -218,7 +217,7 @@ namespace Wabbajack.Lib.Downloaders
{
try
{
var client = await NexusApiClient.Get();
var client = DownloadDispatcher.GetInstance<NexusDownloader>().Client!;
var modInfo = await client.GetModInfo(Game, ModID);
if (!modInfo.available) return false;
var modFiles = await client.GetModFiles(Game, ModID);

View File

@ -34,9 +34,7 @@ namespace Wabbajack.Lib.NexusApi
{
get
{
if (_userStatus == null)
_userStatus = GetUserStatus();
return _userStatus;
return _userStatus ??= GetUserStatus();
}
}

View File

@ -237,6 +237,7 @@ namespace Wabbajack.Test
fileID=35407";
var state = (AbstractDownloadState)await DownloadDispatcher.ResolveArchive(ini.LoadIniString());
await DownloadDispatcher.PrepareAll(new[] {state});
Assert.NotNull(state);

View File

@ -102,6 +102,7 @@ namespace Wabbajack.Test
if (!src.Exists)
{
var state = DownloadDispatcher.ResolveArchive(url);
await DownloadDispatcher.PrepareAll(new[] {state});
await state.Download(new Archive(state: null!) { Name = "Unknown"}, src);
}
@ -118,8 +119,10 @@ namespace Wabbajack.Test
private async Task<(AbsolutePath Download, AbsolutePath ModFolder)> DownloadAndInstall(Game game, int modId, string modName)
{
await utils.AddMod(modName);
var client = await NexusApiClient.Get();
var resp = await client.GetModFiles(game, modId);
var client = DownloadDispatcher.GetInstance<NexusDownloader>();
await client.Prepare();
var resp = await client.Client!.GetModFiles(game, modId);
var file = resp.files.FirstOrDefault(f => f.is_primary) ?? resp.files.FirstOrDefault(f => !string.IsNullOrEmpty(f.category_name));
var src = _downloadFolder.Combine(file.file_name);

View File

@ -228,8 +228,10 @@ namespace Wabbajack.VirtualFileSystem.Test
private static async Task<AbsolutePath> DownloadMod(Game game, int mod)
{
using var client = await NexusApiClient.Get();
var results = await client.GetModFiles(game, mod);
var client = DownloadDispatcher.GetInstance<NexusDownloader>();
await client.Prepare();
var results = await client.Client!.GetModFiles(game, mod);
var file = results.files.FirstOrDefault(f => f.is_primary) ??
results.files.OrderByDescending(f => f.uploaded_timestamp).First();
return await DownloadNexusFile(game, mod, file);
@ -253,8 +255,10 @@ namespace Wabbajack.VirtualFileSystem.Test
public static async Task<AbsolutePath> DownloadMod(Game game, int mod, int fileId)
{
using var client = await NexusApiClient.Get();
var results = await client.GetModFiles(game, mod);
var client = DownloadDispatcher.GetInstance<NexusDownloader>();
await client.Prepare();
var results = await client.Client!.GetModFiles(game, mod);
var file = results.files.FirstOrDefault(f => f.file_id == fileId);
return await DownloadNexusFile(game, mod, file);