mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
commit
d52b713ec3
@ -43,7 +43,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
||||
var existing = await db.ModListStatus.FindOneAsync(l => l.Id == list.Links.MachineURL);
|
||||
|
||||
var modlist_path = Path.Combine(Consts.ModListDownloadFolder,
|
||||
list.Links.MachineURL + ExtensionManager.Extension);
|
||||
list.Links.MachineURL + Consts.ModListExtension);
|
||||
|
||||
if (list.NeedsDownload(modlist_path))
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
||||
{
|
||||
var existing = await db.ModListStatus.FindOneAsync(l => l.Id == list.Links.MachineURL);
|
||||
|
||||
var modlist_path = Path.Combine(Consts.ModListDownloadFolder, list.Links.MachineURL + ExtensionManager.Extension);
|
||||
var modlist_path = Path.Combine(Consts.ModListDownloadFolder, list.Links.MachineURL + Consts.ModListExtension);
|
||||
|
||||
if (list.NeedsDownload(modlist_path))
|
||||
{
|
||||
|
@ -89,6 +89,8 @@ namespace Wabbajack.Common
|
||||
}
|
||||
|
||||
public static string HashFileExtension => ".xxHash";
|
||||
public static string MetaFileExtension => ".meta";
|
||||
public static string ModListExtension = ".wabbajack";
|
||||
public static string LocalAppDataPath => Path.Combine(KnownFolders.LocalAppData.Path, "Wabbajack");
|
||||
public static string MetricsKeyHeader => "x-metrics-key";
|
||||
|
||||
|
@ -5,15 +5,13 @@ using Microsoft.Win32;
|
||||
|
||||
namespace Wabbajack.Common
|
||||
{
|
||||
public class ExtensionManager
|
||||
public class ModListAssociationManager
|
||||
{
|
||||
[DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
|
||||
|
||||
public static string Extension = ".wabbajack";
|
||||
|
||||
private static readonly string ProgIDPath = "Software\\Classes\\Wabbajack";
|
||||
private static readonly string ExtPath = $"Software\\Classes\\{Extension}";
|
||||
private static readonly string ExtPath = $"Software\\Classes\\{Consts.ModListExtension}";
|
||||
|
||||
private static readonly Dictionary<string, string> ProgIDList = new Dictionary<string, string>
|
||||
{
|
@ -85,7 +85,7 @@ namespace Wabbajack.Common
|
||||
|
||||
public static T Log<T>(T msg) where T : IStatusMessage
|
||||
{
|
||||
LogToFile(msg.ExtendedDescription);
|
||||
LogStraightToFile(msg.ExtendedDescription);
|
||||
LoggerSubj.OnNext(msg);
|
||||
return msg;
|
||||
}
|
||||
@ -108,7 +108,7 @@ namespace Wabbajack.Common
|
||||
|
||||
public static void Error(IException err)
|
||||
{
|
||||
LogToFile($"{err.ShortDescription}\n{err.Exception.StackTrace}");
|
||||
LogStraightToFile($"{err.ShortDescription}\n{err.Exception.StackTrace}");
|
||||
LoggerSubj.OnNext(err);
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ namespace Wabbajack.Common
|
||||
throw err.Exception;
|
||||
}
|
||||
|
||||
private static void LogToFile(string msg)
|
||||
public static void LogStraightToFile(string msg)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
|
@ -42,6 +42,8 @@ namespace Wabbajack.Lib
|
||||
|
||||
public bool ShowReportWhenFinished { get; set; } = true;
|
||||
|
||||
public bool IgnoreMissingFiles { get; set; }
|
||||
|
||||
public ICollection<Archive> SelectedArchives = new List<Archive>();
|
||||
public List<Directive> InstallDirectives = new List<Directive>();
|
||||
public List<RawSourceFile> AllFiles = new List<RawSourceFile>();
|
||||
@ -50,7 +52,7 @@ namespace Wabbajack.Lib
|
||||
public List<IndexedArchive> IndexedArchives = new List<IndexedArchive>();
|
||||
public Dictionary<string, IEnumerable<VirtualFile>> IndexedFiles = new Dictionary<string, IEnumerable<VirtualFile>>();
|
||||
|
||||
public void Info(string msg)
|
||||
public static void Info(string msg)
|
||||
{
|
||||
Utils.Log(msg);
|
||||
}
|
||||
@ -60,7 +62,7 @@ namespace Wabbajack.Lib
|
||||
Queue.Report(msg, 0);
|
||||
}
|
||||
|
||||
public void Error(string msg)
|
||||
public static void Error(string msg)
|
||||
{
|
||||
Utils.Log(msg);
|
||||
throw new Exception(msg);
|
||||
@ -260,5 +262,47 @@ namespace Wabbajack.Lib
|
||||
|
||||
public abstract IEnumerable<ICompilationStep> GetStack();
|
||||
public abstract IEnumerable<ICompilationStep> MakeStack();
|
||||
|
||||
public static void PrintNoMatches(ICollection<NoMatch> noMatches)
|
||||
{
|
||||
const int max = 10;
|
||||
Info($"No match for {noMatches.Count} files");
|
||||
if (noMatches.Count > 0)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var file in noMatches)
|
||||
{
|
||||
if (count++ < max)
|
||||
{
|
||||
Utils.Log($" {file.To} - {file.Reason}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.LogStraightToFile($" {file.To} - {file.Reason}");
|
||||
}
|
||||
if (count == max && noMatches.Count > max)
|
||||
{
|
||||
Utils.Log($" ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckForNoMatchExit(ICollection<NoMatch> noMatches)
|
||||
{
|
||||
if (noMatches.Count > 0)
|
||||
{
|
||||
if (IgnoreMissingFiles)
|
||||
{
|
||||
Info("Continuing even though files were missing at the request of the user.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Info("Exiting due to no way to compile these files");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
var result = source.EvolveTo<NoMatch>();
|
||||
result.Reason = "No Match in Stack";
|
||||
Utils.Log($"No match for: {source.Path}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,6 @@ namespace Wabbajack.Lib
|
||||
|
||||
public dynamic MO2Ini { get; }
|
||||
|
||||
public bool IgnoreMissingFiles { get; set; }
|
||||
|
||||
public string MO2DownloadsFolder
|
||||
{
|
||||
get
|
||||
@ -142,13 +140,13 @@ namespace Wabbajack.Lib
|
||||
UpdateTracker.NextStep("Pre-validating Archives");
|
||||
|
||||
IndexedArchives = Directory.EnumerateFiles(MO2DownloadsFolder)
|
||||
.Where(f => File.Exists(f + ".meta"))
|
||||
.Where(f => File.Exists(f + Consts.MetaFileExtension))
|
||||
.Select(f => new IndexedArchive
|
||||
{
|
||||
File = VFS.Index.ByRootPath[f],
|
||||
Name = Path.GetFileName(f),
|
||||
IniData = (f + ".meta").LoadIniFile(),
|
||||
Meta = File.ReadAllText(f + ".meta")
|
||||
IniData = (f + Consts.MetaFileExtension).LoadIniFile(),
|
||||
Meta = File.ReadAllText(f + Consts.MetaFileExtension)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
@ -239,22 +237,9 @@ namespace Wabbajack.Lib
|
||||
UpdateTracker.NextStep($"Adding {ExtraFiles.Count} that were generated by the stack");
|
||||
results = results.Concat(ExtraFiles).ToArray();
|
||||
|
||||
var nomatch = results.OfType<NoMatch>().ToArray();
|
||||
Info($"No match for {nomatch.Length} files");
|
||||
if (nomatch.Any())
|
||||
{
|
||||
foreach (var file in nomatch)
|
||||
Info($" {file.To} - {file.Reason}");
|
||||
if (IgnoreMissingFiles)
|
||||
{
|
||||
Info("Continuing even though files were missing at the request of the user.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Info("Exiting due to no way to compile these files");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var noMatch = results.OfType<NoMatch>().ToArray();
|
||||
PrintNoMatches(noMatch);
|
||||
if (CheckForNoMatchExit(noMatch)) return false;
|
||||
|
||||
InstallDirectives = results.Where(i => !(i is IgnoredDirectly)).ToList();
|
||||
|
||||
@ -339,12 +324,14 @@ namespace Wabbajack.Lib
|
||||
private async Task InferMetas()
|
||||
{
|
||||
var to_find = Directory.EnumerateFiles(MO2DownloadsFolder)
|
||||
.Where(f => !f.EndsWith(".meta") && !f.EndsWith(Consts.HashFileExtension))
|
||||
.Where(f => !File.Exists(f + ".meta"))
|
||||
.Where(f => !f.EndsWith(Consts.MetaFileExtension) && !f.EndsWith(Consts.HashFileExtension))
|
||||
.Where(f => !File.Exists(f + Consts.MetaFileExtension))
|
||||
.ToList();
|
||||
|
||||
if (to_find.Count == 0) return;
|
||||
|
||||
Utils.Log($"Attempting to infer {to_find.Count} metas from the server.");
|
||||
|
||||
await to_find.PMap(Queue, async f =>
|
||||
{
|
||||
var vf = VFS.Index.ByFullPath[f];
|
||||
@ -357,7 +344,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
var ini_data = await response.Content.ReadAsStringAsync();
|
||||
Utils.Log($"Inferred .meta for {Path.GetFileName(vf.FullPath)}, writing to disk");
|
||||
File.WriteAllText(vf.FullPath + ".meta", ini_data);
|
||||
File.WriteAllText(vf.FullPath + Consts.MetaFileExtension, ini_data);
|
||||
});
|
||||
}
|
||||
|
||||
@ -367,7 +354,7 @@ namespace Wabbajack.Lib
|
||||
Utils.Log($"Including {SelectedArchives.Count} .meta files for downloads");
|
||||
await SelectedArchives.PMap(Queue, a =>
|
||||
{
|
||||
var source = Path.Combine(MO2DownloadsFolder, a.Name + ".meta");
|
||||
var source = Path.Combine(MO2DownloadsFolder, a.Name + Consts.MetaFileExtension);
|
||||
InstallDirectives.Add(new ArchiveMeta()
|
||||
{
|
||||
SourceDataID = IncludeFile(File.ReadAllText(source)),
|
||||
|
@ -361,7 +361,7 @@ namespace Wabbajack.Lib
|
||||
foreach (var file in Directory.EnumerateFiles(path))
|
||||
{
|
||||
if (!File.Exists(file)) continue;
|
||||
if (System.IO.Path.GetExtension(file).Equals(ExtensionManager.Extension))
|
||||
if (System.IO.Path.GetExtension(file).Equals(Consts.ModListExtension))
|
||||
{
|
||||
return ErrorResponse.Fail($"Cannot install into a folder with a Wabbajack ModList inside of it");
|
||||
}
|
||||
|
@ -35,8 +35,6 @@ namespace Wabbajack.Lib
|
||||
public string StagingFolder { get; set; }
|
||||
public string DownloadsFolder { get; set; }
|
||||
|
||||
public bool IgnoreMissingFiles { get; set; }
|
||||
|
||||
public override ModManager ModManager => ModManager.Vortex;
|
||||
public override string GamePath { get; }
|
||||
public override string ModListOutputFolder => "output_folder";
|
||||
@ -63,7 +61,7 @@ namespace Wabbajack.Lib
|
||||
if (string.IsNullOrEmpty(ModListName))
|
||||
{
|
||||
ModListName = $"Vortex ModList for {Game.ToString()}";
|
||||
ModListOutputFile = $"{ModListName}{ExtensionManager.Extension}";
|
||||
ModListOutputFile = $"{ModListName}{Consts.ModListExtension}";
|
||||
}
|
||||
|
||||
GameName = Game.MetaData().NexusName;
|
||||
@ -129,13 +127,13 @@ namespace Wabbajack.Lib
|
||||
|
||||
Info("Indexing Archives");
|
||||
IndexedArchives = Directory.EnumerateFiles(DownloadsFolder)
|
||||
.Where(f => File.Exists(f + ".meta"))
|
||||
.Where(f => File.Exists(f + Consts.MetaFileExtension))
|
||||
.Select(f => new IndexedArchive
|
||||
{
|
||||
File = VFS.Index.ByRootPath[f],
|
||||
Name = Path.GetFileName(f),
|
||||
IniData = (f + ".meta").LoadIniFile(),
|
||||
Meta = File.ReadAllText(f + ".meta")
|
||||
IniData = (f + Consts.MetaFileExtension).LoadIniFile(),
|
||||
Meta = File.ReadAllText(f + Consts.MetaFileExtension)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
@ -214,22 +212,9 @@ namespace Wabbajack.Lib
|
||||
Info("Running Compilation Stack");
|
||||
var results = await AllFiles.PMap(Queue, f => RunStack(stack.Where(s => s != null), f));
|
||||
|
||||
IEnumerable<NoMatch> noMatch = results.OfType<NoMatch>().ToList();
|
||||
Info($"No match for {noMatch.Count()} files");
|
||||
foreach (var file in noMatch)
|
||||
Info($" {file.To} - {file.Reason}");
|
||||
if (noMatch.Any())
|
||||
{
|
||||
if (IgnoreMissingFiles)
|
||||
{
|
||||
Info("Continuing even though files were missing at the request of the user.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Info("Exiting due to no way to compile these files");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var noMatch = results.OfType<NoMatch>().ToList();
|
||||
PrintNoMatches(noMatch);
|
||||
if (CheckForNoMatchExit(noMatch)) return false;
|
||||
|
||||
InstallDirectives = results.Where(i => !(i is IgnoredDirectly)).ToList();
|
||||
|
||||
@ -346,7 +331,7 @@ namespace Wabbajack.Lib
|
||||
var nexusClient = await NexusApiClient.Get();
|
||||
|
||||
var archives = Directory.EnumerateFiles(DownloadsFolder, "*", SearchOption.TopDirectoryOnly).Where(f =>
|
||||
File.Exists(f) && Path.GetExtension(f) != ".meta" && Path.GetExtension(f) != ".xxHash" &&
|
||||
File.Exists(f) && Path.GetExtension(f) != Consts.MetaFileExtension && Path.GetExtension(f) != Consts.HashFileExtension &&
|
||||
!File.Exists($"{f}.meta") && ActiveArchives.Contains(Path.GetFileNameWithoutExtension(f)));
|
||||
|
||||
await archives.PMap(Queue, async f =>
|
||||
@ -374,7 +359,7 @@ namespace Wabbajack.Lib
|
||||
$"fileID={md5Response[0].file_details.file_id}\n" +
|
||||
$"version={md5Response[0].file_details.version}\n" +
|
||||
$"hash={hash}\n";
|
||||
File.WriteAllText(f + ".meta", metaString, Encoding.UTF8);
|
||||
File.WriteAllText(f + Consts.MetaFileExtension, metaString, Encoding.UTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -383,7 +368,7 @@ namespace Wabbajack.Lib
|
||||
});
|
||||
|
||||
var otherFiles = Directory.EnumerateFiles(DownloadsFolder, "*", SearchOption.TopDirectoryOnly).Where(f =>
|
||||
Path.GetExtension(f) == ".meta" && !ActiveArchives.Contains(Path.GetFileNameWithoutExtension(f)));
|
||||
Path.GetExtension(f) == Consts.MetaFileExtension && !ActiveArchives.Contains(Path.GetFileNameWithoutExtension(f)));
|
||||
|
||||
await otherFiles.PMap(Queue, async f =>
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ namespace Wabbajack.Lib
|
||||
await ModList.Directives.OfType<InlineFile>()
|
||||
.PMap(Queue,directive =>
|
||||
{
|
||||
if (directive.To.EndsWith(".meta"))
|
||||
if (directive.To.EndsWith(Consts.MetaFileExtension))
|
||||
return;
|
||||
|
||||
Info($"Writing included file {directive.To}");
|
||||
|
@ -38,7 +38,7 @@ namespace Wabbajack.Test
|
||||
var compiler = new MO2Compiler(
|
||||
mo2Folder: utils.MO2Folder,
|
||||
mo2Profile: profile,
|
||||
outputFile: profile + ExtensionManager.Extension);
|
||||
outputFile: profile + Consts.ModListExtension);
|
||||
compiler.ShowReportWhenFinished = false;
|
||||
Assert.IsTrue(await compiler.Begin());
|
||||
return compiler;
|
||||
|
@ -51,7 +51,7 @@ namespace Wabbajack.Test
|
||||
vortexFolder: VortexCompiler.TypicalVortexFolder(),
|
||||
downloadsFolder: VortexCompiler.RetrieveDownloadLocation(utils.Game),
|
||||
stagingFolder: VortexCompiler.RetrieveStagingLocation(utils.Game),
|
||||
outputFile: $"test{ExtensionManager.Extension}");
|
||||
outputFile: $"test{Consts.ModListExtension}");
|
||||
}
|
||||
|
||||
protected async Task<ModList> CompileAndInstall()
|
||||
|
@ -76,7 +76,7 @@ namespace Wabbajack.Test
|
||||
var compiler = new MO2Compiler(
|
||||
mo2Folder: utils.InstallFolder,
|
||||
mo2Profile: profile,
|
||||
outputFile: profile + ExtensionManager.Extension);
|
||||
outputFile: profile + Consts.ModListExtension);
|
||||
compiler.MO2DownloadsFolder = Path.Combine(utils.DownloadsFolder);
|
||||
compiler.ShowReportWhenFinished = false;
|
||||
Assert.IsTrue(await compiler.Begin());
|
||||
@ -137,7 +137,7 @@ namespace Wabbajack.Test
|
||||
|
||||
await FileExtractor.ExtractAll(Queue, src, Path.Combine(utils.ModsFolder, mod_name));
|
||||
|
||||
File.WriteAllText(dest + ".meta", ini);
|
||||
File.WriteAllText(dest + Consts.MetaFileExtension, ini);
|
||||
}
|
||||
|
||||
private async Task<ModList> CompileAndInstall(string profile)
|
||||
@ -165,7 +165,7 @@ namespace Wabbajack.Test
|
||||
var compiler = new MO2Compiler(
|
||||
mo2Folder: utils.MO2Folder,
|
||||
mo2Profile: profile,
|
||||
outputFile: profile + ExtensionManager.Extension);
|
||||
outputFile: profile + Consts.ModListExtension);
|
||||
compiler.ShowReportWhenFinished = false;
|
||||
Assert.IsTrue(await compiler.Begin());
|
||||
return compiler;
|
||||
|
@ -47,7 +47,7 @@ namespace Wabbajack.Test
|
||||
using (var tempDir = new TempFolder())
|
||||
{
|
||||
File.Create(Path.Combine(tempDir.Dir.FullName, $"ModOrganizer.exe"));
|
||||
File.Create(Path.Combine(tempDir.Dir.FullName, $"modlist{ExtensionManager.Extension}"));
|
||||
File.Create(Path.Combine(tempDir.Dir.FullName, $"modlist{Consts.ModListExtension}"));
|
||||
Assert.IsFalse(MO2Installer.CheckValidInstallPath(tempDir.Dir.FullName, downloadFolder: null).Succeeded);
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ namespace Wabbajack.Test
|
||||
});
|
||||
}
|
||||
|
||||
File.WriteAllLines(Path.Combine(DownloadsFolder, name+".meta"),
|
||||
File.WriteAllLines(Path.Combine(DownloadsFolder, name + Consts.MetaFileExtension),
|
||||
|
||||
new string[]
|
||||
{
|
||||
|
@ -168,11 +168,11 @@ namespace Wabbajack
|
||||
string outputFile;
|
||||
if (string.IsNullOrWhiteSpace(Parent.OutputLocation.TargetPath))
|
||||
{
|
||||
outputFile = MOProfile + ExtensionManager.Extension;
|
||||
outputFile = MOProfile + Consts.ModListExtension;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputFile = Path.Combine(Parent.OutputLocation.TargetPath, MOProfile + ExtensionManager.Extension);
|
||||
outputFile = Path.Combine(Parent.OutputLocation.TargetPath, MOProfile + Consts.ModListExtension);
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -179,7 +179,7 @@ namespace Wabbajack
|
||||
|
||||
public async Task<bool> Compile()
|
||||
{
|
||||
string outputFile = $"{ModlistSettings.ModListName}{ExtensionManager.Extension}";
|
||||
string outputFile = $"{ModlistSettings.ModListName}{Consts.ModListExtension}";
|
||||
if (!string.IsNullOrWhiteSpace(Parent.OutputLocation.TargetPath))
|
||||
{
|
||||
outputFile = Path.Combine(Parent.OutputLocation.TargetPath, outputFile);
|
||||
|
@ -52,7 +52,7 @@ namespace Wabbajack
|
||||
{
|
||||
_parent = parent;
|
||||
Metadata = metadata;
|
||||
Location = Path.Combine(Consts.ModListDownloadFolder, Metadata.Links.MachineURL + ExtensionManager.Extension);
|
||||
Location = Path.Combine(Consts.ModListDownloadFolder, Metadata.Links.MachineURL + Consts.ModListExtension);
|
||||
IsBroken = metadata.ValidationSummary.HasFailures;
|
||||
OpenWebsiteCommand = ReactiveCommand.Create(() => Process.Start($"https://www.wabbajack.org/modlist/{Metadata.Links.MachineURL}"));
|
||||
ExecuteCommand = ReactiveCommand.CreateFromObservable<Unit, Unit>(
|
||||
|
@ -27,7 +27,7 @@ namespace Wabbajack
|
||||
if (string.IsNullOrWhiteSpace(path)
|
||||
|| !File.Exists(path))
|
||||
{
|
||||
path = UIUtils.OpenFileDialog($"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}");
|
||||
path = UIUtils.OpenFileDialog($"*{Consts.ModListExtension}|*{Consts.ModListExtension}");
|
||||
}
|
||||
_mainVM.OpenInstaller(path);
|
||||
});
|
||||
|
@ -36,9 +36,9 @@ namespace Wabbajack
|
||||
var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
try
|
||||
{
|
||||
if (!ExtensionManager.IsAssociated() || ExtensionManager.NeedsUpdating(appPath))
|
||||
if (!ModListAssociationManager.IsAssociated() || ModListAssociationManager.NeedsUpdating(appPath))
|
||||
{
|
||||
ExtensionManager.Associate(appPath);
|
||||
ModListAssociationManager.Associate(appPath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
Loading…
Reference in New Issue
Block a user