mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Add modlist metadata to the compiler output and the list validation
This commit is contained in:
parent
f2efdeef9d
commit
eda43c0df6
@ -15,6 +15,7 @@ using VFS;
|
|||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack.Lib.CompilationSteps;
|
using Wabbajack.Lib.CompilationSteps;
|
||||||
using Wabbajack.Lib.Downloaders;
|
using Wabbajack.Lib.Downloaders;
|
||||||
|
using Wabbajack.Lib.ModListRegistry;
|
||||||
using Wabbajack.Lib.NexusApi;
|
using Wabbajack.Lib.NexusApi;
|
||||||
using Wabbajack.Lib.Validation;
|
using Wabbajack.Lib.Validation;
|
||||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||||
@ -346,6 +347,16 @@ namespace Wabbajack.Lib
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils.Log("Exporting Modlist metadata");
|
||||||
|
var metadata = new ModlistMetadata.DownloadMetadata
|
||||||
|
{
|
||||||
|
Size = File.GetSize(ModListOutputFile),
|
||||||
|
Hash = ModListOutputFile.FileHash()
|
||||||
|
};
|
||||||
|
metadata.ToJSON(ModListOutputFile + ".meta.json");
|
||||||
|
|
||||||
|
|
||||||
Utils.Log("Removing modlist staging folder");
|
Utils.Log("Removing modlist staging folder");
|
||||||
Directory.Delete(ModListOutputFolder, true);
|
Directory.Delete(ModListOutputFolder, true);
|
||||||
|
|
||||||
|
@ -51,11 +51,21 @@ namespace Wabbajack.Lib.ModListRegistry
|
|||||||
[JsonProperty("download")]
|
[JsonProperty("download")]
|
||||||
public string Download { get; set; }
|
public string Download { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("download_metadata")]
|
||||||
|
public DownloadMetadata DownloadMetadata { get; set; }
|
||||||
|
|
||||||
[JsonProperty("machineURL")]
|
[JsonProperty("machineURL")]
|
||||||
public string MachineURL { get; set; }
|
public string MachineURL { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class DownloadMetadata
|
||||||
|
{
|
||||||
|
public string Hash { get; set; }
|
||||||
|
public long Size { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<ModlistMetadata> LoadFromGithub()
|
public static List<ModlistMetadata> LoadFromGithub()
|
||||||
{
|
{
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
@ -63,5 +73,16 @@ namespace Wabbajack.Lib.ModListRegistry
|
|||||||
var result = client.GetStringSync(Consts.ModlistMetadataURL);
|
var result = client.GetStringSync(Consts.ModlistMetadataURL);
|
||||||
return result.FromJSONString<List<ModlistMetadata>>();
|
return result.FromJSONString<List<ModlistMetadata>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool NeedsDownload(string modlistPath)
|
||||||
|
{
|
||||||
|
if (!File.Exists(modlistPath)) return true;
|
||||||
|
if (Links.DownloadMetadata?.Hash == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Links.DownloadMetadata.Hash != modlistPath.FileHash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -36,13 +36,19 @@ namespace Wabbajack.Test.ListValidation
|
|||||||
public void ValidateModLists(string name, ModlistMetadata list)
|
public void ValidateModLists(string name, ModlistMetadata list)
|
||||||
{
|
{
|
||||||
Log($"Testing {list.Links.MachineURL} - {list.Title}");
|
Log($"Testing {list.Links.MachineURL} - {list.Title}");
|
||||||
|
|
||||||
var state = DownloadDispatcher.ResolveArchive(list.Links.Download);
|
|
||||||
|
|
||||||
Log($"Downloading {list.Links.MachineURL} - {list.Title}");
|
|
||||||
|
|
||||||
var modlist_path = Path.Combine(Consts.ModListDownloadFolder, list.Links.MachineURL + ".wabbajack");
|
var modlist_path = Path.Combine(Consts.ModListDownloadFolder, list.Links.MachineURL + ".wabbajack");
|
||||||
|
|
||||||
|
if (list.NeedsDownload(modlist_path))
|
||||||
|
{
|
||||||
|
var state = DownloadDispatcher.ResolveArchive(list.Links.Download);
|
||||||
|
Log($"Downloading {list.Links.MachineURL} - {list.Title}");
|
||||||
state.Download(modlist_path);
|
state.Download(modlist_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log($"No changes detected from downloaded modlist");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Log($"Loading {modlist_path}");
|
Log($"Loading {modlist_path}");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user