mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Write meta files for every download file
This commit is contained in:
parent
032b90e3bf
commit
eee4881c8b
@ -134,7 +134,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
|||||||
|
|
||||||
await InstallIncludedFiles(token);
|
await InstallIncludedFiles(token);
|
||||||
|
|
||||||
await InstallIncludedDownloadMetas(token);
|
await WriteMetaFiles(token);
|
||||||
|
|
||||||
await BuildBSAs(token);
|
await BuildBSAs(token);
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task InstallIncludedDownloadMetas(CancellationToken token)
|
private async Task WriteMetaFiles(CancellationToken token)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Looking for downloads by size");
|
_logger.LogInformation("Looking for downloads by size");
|
||||||
var bySize = UnoptimizedArchives.ToLookup(x => x.Size);
|
var bySize = UnoptimizedArchives.ToLookup(x => x.Size);
|
||||||
@ -231,12 +231,49 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
|||||||
await _configuration.Downloads.EnumerateFiles()
|
await _configuration.Downloads.EnumerateFiles()
|
||||||
.PDoAll(async download =>
|
.PDoAll(async download =>
|
||||||
{
|
{
|
||||||
|
var metaFile = download.WithExtension(Ext.Meta);
|
||||||
|
|
||||||
var found = bySize[download.Size()];
|
var found = bySize[download.Size()];
|
||||||
var hash = await FileHashCache.FileHashCachedAsync(download, token);
|
var hash = await FileHashCache.FileHashCachedAsync(download, token);
|
||||||
var archive = found.FirstOrDefault(f => f.Hash == hash);
|
var archive = found.FirstOrDefault(f => f.Hash == hash);
|
||||||
if (archive == default) return;
|
|
||||||
|
|
||||||
var metaFile = download.WithExtension(Ext.Meta);
|
IEnumerable<string> meta;
|
||||||
|
|
||||||
|
if (archive == default)
|
||||||
|
{
|
||||||
|
// archive is not part of the Modlist
|
||||||
|
|
||||||
|
if (metaFile.FileExists())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var parsed = metaFile.LoadIniFile();
|
||||||
|
if (parsed["General"] is not null && parsed["General"]["removed"] is null)
|
||||||
|
{
|
||||||
|
// add removed=true to files not part of the Modlist so they don't show up in MO2
|
||||||
|
parsed["General"]["removed"] = "true";
|
||||||
|
|
||||||
|
_logger.LogInformation("Writing {FileName}", metaFile.FileName);
|
||||||
|
parsed.SaveIniFile(metaFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new meta file if missing
|
||||||
|
meta = new[]
|
||||||
|
{
|
||||||
|
"[General]",
|
||||||
|
"removed=true"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (metaFile.FileExists())
|
if (metaFile.FileExists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -250,21 +287,22 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// Ignore
|
// ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta = AddInstalled(_downloadDispatcher.MetaIni(archive));
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Writing {FileName}", metaFile.FileName);
|
_logger.LogInformation("Writing {FileName}", metaFile.FileName);
|
||||||
var meta = AddInstalled(_downloadDispatcher.MetaIni(archive));
|
|
||||||
await metaFile.WriteAllLinesAsync(meta, token);
|
await metaFile.WriteAllLinesAsync(meta, token);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> AddInstalled(IEnumerable<string> getMetaIni)
|
private static IEnumerable<string> AddInstalled(IEnumerable<string> getMetaIni)
|
||||||
{
|
{
|
||||||
yield return "[General]";
|
yield return "[General]";
|
||||||
yield return "installed=true";
|
yield return "installed=true";
|
||||||
yield return "removed=true";
|
|
||||||
|
|
||||||
foreach (var f in getMetaIni)
|
foreach (var f in getMetaIni)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user