mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
All sanity tests work!
This commit is contained in:
parent
a847d69851
commit
1ebb0b6492
@ -101,12 +101,18 @@ namespace Wabbajack.Lib
|
||||
return id;
|
||||
}
|
||||
|
||||
internal async Task<RelativePath> IncludeFile(AbsolutePath data)
|
||||
internal async Task<RelativePath> IncludeFile(Stream data)
|
||||
{
|
||||
var id = IncludeId();
|
||||
await data.CopyToAsync(ModListOutputFolder.Combine(id));
|
||||
await ModListOutputFolder.Combine(id).WriteAllAsync(data);
|
||||
return id;
|
||||
}
|
||||
|
||||
internal async Task<RelativePath> IncludeFile(AbsolutePath data)
|
||||
{
|
||||
await using var stream = await data.OpenRead();
|
||||
return await IncludeFile(stream);
|
||||
}
|
||||
|
||||
|
||||
internal async Task<(RelativePath, AbsolutePath)> IncludeString(string str)
|
||||
@ -302,6 +308,27 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task InlineFiles()
|
||||
{
|
||||
var grouped = ModList.Directives.OfType<InlineFile>()
|
||||
.Where(f => f.SourceDataID == default)
|
||||
.GroupBy(f => f.SourceDataFile)
|
||||
.ToDictionary(f => f.Key);
|
||||
|
||||
await VFS.Extract(Queue, grouped.Keys.ToHashSet(), async (vf, sfn) =>
|
||||
{
|
||||
await using var stream = await sfn.GetStream();
|
||||
var id = await IncludeFile(stream);
|
||||
foreach (var file in grouped[vf])
|
||||
{
|
||||
file.SourceDataID = id;
|
||||
file.SourceDataFile = null;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public bool CheckForNoMatchExit(ICollection<NoMatch> noMatches)
|
||||
{
|
||||
if (noMatches.Count > 0)
|
||||
|
@ -87,7 +87,11 @@ namespace Wabbajack.Lib
|
||||
|
||||
public async Task<byte[]> LoadBytesFromPath(RelativePath path)
|
||||
{
|
||||
return await ExtractedModlistFolder!.Dir.Combine(path).ReadAllBytesAsync();
|
||||
var fullPath = ExtractedModlistFolder!.Dir.Combine(path);
|
||||
if (!fullPath.IsFile)
|
||||
throw new Exception($"Cannot load inlined data {path} file does not exist");
|
||||
|
||||
return await fullPath.ReadAllBytesAsync();
|
||||
}
|
||||
|
||||
public static ModList LoadFromFile(AbsolutePath path)
|
||||
@ -140,7 +144,27 @@ namespace Wabbajack.Lib
|
||||
foreach (var directive in grouped[vf])
|
||||
{
|
||||
s.Position = 0;
|
||||
await directive.Directive.To.RelativeTo(OutputFolder).WriteAllAsync(s, false);
|
||||
|
||||
switch (directive.Directive)
|
||||
{
|
||||
case PatchedFromArchive pfa:
|
||||
{
|
||||
var patchData = await LoadBytesFromPath(pfa.PatchID);
|
||||
await using var os = await directive.Directive.To.RelativeTo(OutputFolder).Create();
|
||||
Utils.ApplyPatch(s, () => new MemoryStream(patchData), os);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case FromArchive _:
|
||||
await directive.Directive.To.RelativeTo(OutputFolder).WriteAllAsync(s, false);
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"No handler for {directive}");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
Func<Task>? _cleanup = null;
|
||||
if (defaultInclude)
|
||||
{
|
||||
_cleanup = await source.File.Context.Stage(source.File.Children);
|
||||
//_cleanup = await source.File.Context.Stage(source.File.Children);
|
||||
}
|
||||
|
||||
var matches = await sourceFiles.PMap(_mo2Compiler.Queue, e => _mo2Compiler.RunStack(stack, new RawSourceFile(e, Consts.BSACreationDir.Combine((RelativePath)id, (RelativePath)e.Name))));
|
||||
|
@ -14,8 +14,7 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
var inline = source.EvolveTo<InlineFile>();
|
||||
await using var file = await source.File.StagedFile.OpenRead();
|
||||
inline.SourceDataID = await _compiler.IncludeFile(await file.ReadAllAsync());
|
||||
inline.SourceDataFile = source.File;
|
||||
return inline;
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,9 @@ namespace Wabbajack.Lib
|
||||
/// Data that will be written as-is to the destination location;
|
||||
/// </summary>
|
||||
public RelativePath SourceDataID { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public VirtualFile? SourceDataFile { get; set; }
|
||||
}
|
||||
|
||||
[JsonName("ArchiveMeta")]
|
||||
|
@ -57,7 +57,7 @@ namespace Wabbajack.Lib
|
||||
public HashSet<string> SelectedProfiles { get; set; } = new HashSet<string>();
|
||||
|
||||
public MO2Compiler(AbsolutePath mo2Folder, string mo2Profile, AbsolutePath outputFile)
|
||||
: base(steps: 20)
|
||||
: base(steps: 21)
|
||||
{
|
||||
MO2Folder = mo2Folder;
|
||||
MO2Profile = mo2Profile;
|
||||
@ -352,6 +352,9 @@ namespace Wabbajack.Lib
|
||||
Version = ModlistVersion ?? new Version(1,0,0,0),
|
||||
IsNSFW = ModlistIsNSFW
|
||||
};
|
||||
|
||||
UpdateTracker.NextStep("Including required files");
|
||||
await InlineFiles();
|
||||
|
||||
UpdateTracker.NextStep("Running Validation");
|
||||
|
||||
@ -370,7 +373,6 @@ namespace Wabbajack.Lib
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public Dictionary<Game, HashSet<Hash>> GameHashes { get; set; } = new Dictionary<Game, HashSet<Hash>>();
|
||||
public Dictionary<Hash, Game[]> GamesWithHashes { get; set; } = new Dictionary<Hash, Game[]>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user