diff --git a/Wabbajack.BuildServer/Models/Jobs/UpdateModLists.cs b/Wabbajack.BuildServer/Models/Jobs/UpdateModLists.cs index 1d749211..77af3e23 100644 --- a/Wabbajack.BuildServer/Models/Jobs/UpdateModLists.cs +++ b/Wabbajack.BuildServer/Models/Jobs/UpdateModLists.cs @@ -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 diff --git a/Wabbajack.CLI/Verbs/DownloadUrl.cs b/Wabbajack.CLI/Verbs/DownloadUrl.cs index 9ea450a2..f6a849d8 100644 --- a/Wabbajack.CLI/Verbs/DownloadUrl.cs +++ b/Wabbajack.CLI/Verbs/DownloadUrl.cs @@ -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 diff --git a/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs b/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs index 645c1f9f..d8c755a0 100644 --- a/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs +++ b/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs @@ -58,7 +58,7 @@ namespace Wabbajack.Lib.Downloaders public static T GetInstance() 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().Select(d => d.GetDownloaderState(url)).FirstOrDefault(result => result != null); } - public static void PrepareAll(IEnumerable states) + public static async Task PrepareAll(IEnumerable 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 DownloadWithPossibleUpgrade(Archive archive, AbsolutePath destination) diff --git a/Wabbajack.Test/DownloaderTests.cs b/Wabbajack.Test/DownloaderTests.cs index f3c6c4d1..ed1614d8 100644 --- a/Wabbajack.Test/DownloaderTests.cs +++ b/Wabbajack.Test/DownloaderTests.cs @@ -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]