Merge pull request #832 from wabbajack-tools/faster-inlined-file-installation

Speed up loading of patches and inlined files.
This commit is contained in:
Timothy Baldridge 2020-05-13 04:10:29 -07:00 committed by GitHub
commit 4357564347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View File

@ -33,6 +33,7 @@ namespace Wabbajack.Lib
public SystemParameters? SystemParameters { get; set; }
public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters? parameters, int steps, Game game)
: base(steps)
{
@ -44,6 +45,14 @@ namespace Wabbajack.Lib
Game = game.MetaData();
}
private ExtractedFiles? ExtractedModListFiles { get; set; } = null;
public async Task ExtractModlist()
{
ExtractedModListFiles = await FileExtractor.ExtractAll(Queue, ModListArchive);
}
public void Info(string msg)
{
Utils.Log(msg);
@ -62,16 +71,8 @@ namespace Wabbajack.Lib
public async Task<byte[]> LoadBytesFromPath(RelativePath path)
{
await using var fs = new FileStream((string)ModListArchive, FileMode.Open, FileAccess.Read, FileShare.Read);
using var ar = new ZipArchive(fs, ZipArchiveMode.Read);
await using var ms = new MemoryStream();
var entry = ar.GetEntry((string)path);
await using (var e = entry.Open())
{
await e.CopyToAsync(ms);
}
return ms.ToArray();
await using var e = ExtractedModListFiles![path].OpenRead();
return await e.ReadAllAsync();
}
public static ModList LoadFromFile(AbsolutePath path)

View File

@ -39,7 +39,7 @@ namespace Wabbajack.Lib
outputFolder: outputFolder,
downloadFolder: downloadFolder,
parameters: parameters,
steps: 20,
steps: 21,
game: modList.GameType)
{
var gameExe = Consts.GameFolderFilesDir.Combine(modList.GameType.MetaData().MainExecutable!);
@ -129,6 +129,10 @@ namespace Wabbajack.Lib
Error("Cannot continue, was unable to download one or more archives");
}
if (cancel.IsCancellationRequested) return false;
UpdateTracker.NextStep("Extracting Modlist contents");
await ExtractModlist();
if (cancel.IsCancellationRequested) return false;
UpdateTracker.NextStep("Priming VFS");
await PrimeVFS();