Fixup missing .meta file when WJ uses a separate download folder

This commit is contained in:
Timothy Baldridge 2019-11-03 21:36:25 -07:00
parent f39fe51328
commit b8471a41b3
6 changed files with 51 additions and 3 deletions

View File

@ -16,6 +16,7 @@ namespace Wabbajack.Lib
typeof(NoMatch), typeof(InlineFile), typeof(PropertyType), typeof(CleanedESM),
typeof(RemappedInlineFile), typeof(FromArchive), typeof(CreateBSA), typeof(PatchedFromArchive),
typeof(SourcePatch), typeof(MergedPatch), typeof(Archive), typeof(IndexedArchive), typeof(IndexedEntry),
typeof(ArchiveMeta),
typeof(IndexedArchiveEntry), typeof(BSAIndexedEntry), typeof(VirtualFile),
typeof(ArchiveStateObject), typeof(FileStateObject), typeof(IDownloader),
typeof(IUrlDownloader), typeof(AbstractDownloadState), typeof(ManualDownloader.State),

View File

@ -273,6 +273,7 @@ namespace Wabbajack.Lib
zEditIntegration.VerifyMerges(this);
GatherArchives();
IncludeArchiveMetadata();
BuildPatches();
ModList = new ModList
@ -302,6 +303,22 @@ namespace Wabbajack.Lib
return true;
}
private void IncludeArchiveMetadata()
{
Utils.Log($"Including {SelectedArchives.Count} .meta files for downloads");
SelectedArchives.Do(a =>
{
var source = Path.Combine(MO2DownloadsFolder, a.Name + ".meta");
InstallDirectives.Add(new ArchiveMeta()
{
SourceDataID = IncludeFile(File.ReadAllText(source)),
Size = File.GetSize(source),
Hash = source.FileHash(),
To = Path.GetFileName(source)
});
});
}
private void ExportModlist()
{
Utils.Log($"Exporting Modlist to : {ModListOutputFile}");
@ -540,7 +557,6 @@ namespace Wabbajack.Lib
{
new IncludePropertyFiles(this),
new IgnoreStartsWith(this,"logs\\"),
new IncludeRegex(this, "^downloads\\\\.*\\.meta"),
new IgnoreStartsWith(this, "downloads\\"),
new IgnoreStartsWith(this,"webcache\\"),
new IgnoreStartsWith(this, "overwrite\\"),

View File

@ -118,6 +118,11 @@ namespace Wabbajack.Lib
public string SourceDataID;
}
public class ArchiveMeta : Directive
{
public string SourceDataID;
}
public enum PropertyType { Banner, Readme }
/// <summary>

View File

@ -155,6 +155,7 @@ namespace Wabbajack.Lib
BuildFolderStructure();
InstallArchives();
InstallIncludedFiles();
InctallIncludedDownloadMetas();
BuildBSAs();
zEditIntegration.GenerateMerges(this);
@ -165,6 +166,19 @@ namespace Wabbajack.Lib
//AskToEndorse();
}
private void InctallIncludedDownloadMetas()
{
ModList.Directives
.OfType<ArchiveMeta>()
.PMap(directive =>
{
Status($"Writing included .meta file {directive.To}");
var out_path = Path.Combine(DownloadFolder, directive.To);
if (File.Exists(out_path)) File.Delete(out_path);
File.WriteAllBytes(out_path, LoadBytesFromPath(directive.SourceDataID));
});
}
private void ValidateGameESMs()
{
foreach (var esm in ModList.Directives.OfType<CleanedESM>().ToList())

View File

@ -63,6 +63,17 @@ namespace Wabbajack.Test
var modlist = CompileAndInstall(profile);
utils.VerifyAllFiles();
Directory.Delete(Path.Combine(utils.InstallFolder, "LOOT Config Files"), true);
VirtualFileSystem.Reconfigure(utils.TestFolder);
var compiler = new Compiler(utils.InstallFolder);
compiler.MO2DownloadsFolder = Path.Combine(utils.DownloadsFolder);
compiler.VFS.Reset();
compiler.MO2Profile = profile;
compiler.ShowReportWhenFinished = false;
Assert.IsTrue(compiler.Compile());
}
private void DownloadAndInstall(string url, string filename, string mod_name = null)

View File

@ -50,6 +50,7 @@ namespace Wabbajack.Test
"[General]",
$"gameName={GameName}",
$"gamePath={GameFolder.Replace("\\", "\\\\")}",
$"download_directory={DownloadsFolder}"
});
Directory.CreateDirectory(DownloadsFolder);