Make file copying parallel during compilation

This commit is contained in:
Timothy Baldridge 2019-12-23 16:28:47 -07:00
parent e32be75816
commit 878b1759b2
2 changed files with 11 additions and 4 deletions

View File

@ -311,6 +311,13 @@ namespace Wabbajack.Common
}
}
public static Task PDoIndexed<T>(this IEnumerable<T> coll, WorkQueue queue, Action<int, T> f)
{
return coll.Zip(Enumerable.Range(0, int.MaxValue), (v, idx) => (v, idx))
.PMap(queue, vs=> f(vs.idx, vs.v));
}
/// <summary>
/// Loads INI data from the given filename and returns a dynamic type that

View File

@ -130,10 +130,10 @@ namespace Wabbajack.Lib
.ToList();
Info("Installing Archives");
await archives.PMap(Queue, UpdateTracker,a => InstallArchive(a.Archive, a.AbsolutePath, grouped[a.Archive.Hash]));
await archives.PMap(Queue, UpdateTracker,a => InstallArchive(Queue, a.Archive, a.AbsolutePath, grouped[a.Archive.Hash]));
}
private async Task InstallArchive(Archive archive, string absolutePath, IGrouping<string, FromArchive> grouping)
private async Task InstallArchive(WorkQueue queue, Archive archive, string absolutePath, IGrouping<string, FromArchive> grouping)
{
Status($"Extracting {archive.Name}");
@ -176,8 +176,8 @@ namespace Wabbajack.Lib
File.SetLastWriteTime(to, DateTime.Now);
}
vFiles.GroupBy(f => f.FromFile)
.DoIndexed((idx, group) =>
await vFiles.GroupBy(f => f.FromFile)
.PDoIndexed(queue, (idx, group) =>
{
Utils.Status("Installing files", idx * 100 / vFiles.Count);
var firstDest = Path.Combine(OutputFolder, group.First().To);