Merge pull request #1080 from wabbajack-tools/move-ini-include

Move where we include ini additions
This commit is contained in:
Timothy Baldridge 2020-09-09 19:29:24 -06:00 committed by GitHub
commit 4da8fbb9f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 6 deletions

View File

@ -100,7 +100,7 @@ namespace Wabbajack.Lib.Downloaders
public string GetMetaIniString()
{
return $"{string.Join("\n", GetMetaIni())}\ninstalled=true";
return string.Join("\n", GetMetaIni());
}
public async Task<(Archive? Archive, TempFile NewFile)> ServerFindUpgrade(Archive a)

View File

@ -252,14 +252,34 @@ namespace Wabbajack.Lib
.OfType<ArchiveMeta>()
.PMap(Queue, async directive =>
{
Status($"Writing included .meta file {directive.To}");
var outPath = DownloadFolder.Combine(directive.To);
if (outPath.IsFile) await outPath.DeleteAsync();
var bytes = await LoadBytesFromPath(directive.SourceDataID);
await outPath.WriteAllBytesAsync(bytes);
Status($"Writing .meta file {directive.To}");
foreach (var archive in ModList.Archives)
{
if (HashedArchives.TryGetValue(archive.Hash, out var paths))
{
var metaPath = paths.WithExtension(Consts.MetaFileExtension);
if (!metaPath.Exists)
{
var meta = AddInstalled(archive.State.GetMetaIni()).ToArray();
await metaPath.WriteAllLinesAsync(meta);
}
}
}
});
}
private IEnumerable<string> AddInstalled(string[] getMetaIni)
{
foreach (var f in getMetaIni)
{
yield return f;
if (f == "[General]")
{
yield return "installed=true";
}
}
}
private async ValueTask ValidateGameESMs()
{
foreach (var esm in ModList.Directives.OfType<CleanedESM>().ToList())