Merge pull request #144 from wabbajack-tools/fix-download-meta

Fixup missing .meta file when WJ uses a separate download folder
This commit is contained in:
Timothy Baldridge 2019-11-03 21:56:59 -07:00 committed by GitHub
commit 2c96d08828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 3 deletions

View File

@ -16,8 +16,9 @@ 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(IndexedArchiveEntry), typeof(BSAIndexedEntry), typeof(VirtualFile),
typeof(ArchiveStateObject), typeof(FileStateObject), typeof(IDownloader),
typeof(ArchiveMeta),
typeof(IndexedArchiveEntry), typeof(BSAIndexedEntry), typeof(VirtualFile),
typeof(ArchiveStateObject), typeof(FileStateObject), typeof(IDownloader),
typeof(IUrlDownloader), typeof(AbstractDownloadState), typeof(ManualDownloader.State),
typeof(DropboxDownloader), typeof(GoogleDriveDownloader.State), typeof(HTTPDownloader.State),
typeof(MegaDownloader.State), typeof(ModDBDownloader.State), typeof(NexusDownloader.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,19 @@ namespace Wabbajack.Test
var modlist = CompileAndInstall(profile);
utils.VerifyAllFiles();
var loot_folder = Path.Combine(utils.InstallFolder, "LOOT Config Files");
if (Directory.Exists(loot_folder))
Directory.Delete(loot_folder, 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);