Move where we include ini additions

This commit is contained in:
Timothy Baldridge 2020-09-09 16:50:43 -06:00
parent 3db1f2d9ea
commit c73116a465
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())