Missing IDownloader.Prepare awaits

This commit is contained in:
Justin Swanson 2020-04-10 14:06:32 -05:00
parent 18d5f56f52
commit 482b7f9c9e
4 changed files with 9 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,7 @@ namespace Wabbajack.Lib.Downloaders
public static T GetInstance<T>() where T : IDownloader
{
var inst = (T)IndexedDownloaders[typeof(T)];
inst.Prepare();
inst.Prepare().FireAndForget();
return inst;
}
@ -79,11 +79,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]