Merge pull request #702 from Noggog/missing-prepare-awaits

Missing IDownloader.Prepare awaits
This commit is contained in:
Timothy Baldridge 2020-04-10 22:04:57 -06:00 committed by GitHub
commit ff2397b48b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 9 deletions

View File

@ -44,7 +44,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
return JobResult.Success();
}
private async Task ValidateList(SqlService sql, ModlistMetadata list, WorkQueue queue, ValidateModlist whitelists)
private async Task ValidateList(SqlService sql, ModlistMetadata list, WorkQueue queue, ValidateModlist whitelists)
{
var modlistPath = Consts.ModListDownloadFolder.Combine(list.Links.MachineURL + Consts.ModListExtension);
@ -68,7 +68,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
Utils.Log($"{installer.Archives.Count} archives to validate");
DownloadDispatcher.PrepareAll(installer.Archives.Select(a => a.State));
await DownloadDispatcher.PrepareAll(installer.Archives.Select(a => a.State));
var validated = (await installer.Archives

View File

@ -24,7 +24,7 @@ namespace Wabbajack.CLI.Verbs
if (state == null)
return CLIUtils.Exit($"Could not find download source for URL {Url}", ExitCode.Error);
DownloadDispatcher.PrepareAll(new []{state});
await DownloadDispatcher.PrepareAll(new []{state});
using var queue = new WorkQueue();
queue.Status

View File

@ -58,7 +58,6 @@ namespace Wabbajack.Lib.Downloaders
public static T GetInstance<T>() where T : IDownloader
{
var inst = (T)IndexedDownloaders[typeof(T)];
inst.Prepare();
return inst;
}
@ -79,11 +78,11 @@ namespace Wabbajack.Lib.Downloaders
return Downloaders.OfType<IUrlDownloader>().Select(d => d.GetDownloaderState(url)).FirstOrDefault(result => result != null);
}
public static void PrepareAll(IEnumerable<AbstractDownloadState> states)
public static async Task PrepareAll(IEnumerable<AbstractDownloadState> states)
{
states.Select(s => s.GetDownloader().GetType())
await Task.WhenAll(states.Select(s => s.GetDownloader().GetType())
.Distinct()
.Do(t => Downloaders.First(d => d.GetType() == t).Prepare());
.Select(t => Downloaders.First(d => d.GetType() == t).Prepare()));
}
public static async Task<bool> DownloadWithPossibleUpgrade(Archive archive, AbsolutePath destination)

View File

@ -44,9 +44,9 @@ namespace Wabbajack.Test
}
[Fact]
public void TestAllPrepares()
public async Task TestAllPrepares()
{
DownloadDispatcher.Downloaders.Do(d => d.Prepare());
await Task.WhenAll(DownloadDispatcher.Downloaders.Select(d => d.Prepare()));
}
[Fact]