Merge pull request #2081 from wabbajack-tools/compilation_fixes

Compilation fixes
This commit is contained in:
Timothy Baldridge 2022-09-22 22:26:09 -05:00 committed by GitHub
commit 0774cb663d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 8 deletions

View File

@ -1,5 +1,16 @@
### Changelog
#### Version - 3.0.1.4 - 9/21/2022
* Fix several of case sensitive path comparisons, that could result in deleting downloads
#### Version - 3.0.1.3 - 9/20/2022
* Auto-include splash.png files when compiling
* Fix support for `WABBAJACK_NOMATCH_INCLUDE_FILES.txt` and other variants
* Fix missing MO2ArchiveName for stardewvalley
* Write the name/version of the modlist to the log before installing
* Refuse to install inside a Game folder or the a parent of a game folder
* Refuse to install inside the Wabbajack folder or a parent of the Wabbajack folder
#### Version - 3.0.1.2 - 9/19/2022
* Fix error with FNV BSAs not building properly when files are in the root folder
* Fix for UnknownError in the Launcher (will require the Wabbajack.exe launcher to be re-downloaded)

View File

@ -274,6 +274,29 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
yield return ErrorResponse.Fail("Install path isn't set to a folder");
if (installPath.InFolder(KnownFolders.Windows))
yield return ErrorResponse.Fail("Don't install modlists into your Windows folder");
foreach (var game in GameRegistry.Games)
{
if (!_gameLocator.TryFindLocation(game.Key, out var location))
continue;
if (installPath.InFolder(location))
yield return ErrorResponse.Fail("Can't install a modlist into a game folder");
if (location.ThisAndAllParents().Any(path => installPath == path))
{
yield return ErrorResponse.Fail(
"Can't install in this path, installed files may overwrite important game files");
}
}
if (installPath.InFolder(KnownFolders.EntryPoint))
yield return ErrorResponse.Fail("Can't install a modlist into the Wabbajack.exe path");
if (KnownFolders.EntryPoint.ThisAndAllParents().Any(path => installPath == path))
{
yield return ErrorResponse.Fail("Installing in this folder may overwrite Wabbajack");
}
}

View File

@ -14,7 +14,7 @@ public class IncludeRegex : ACompilationStep
public IncludeRegex(ACompiler compiler, string pattern) : base(compiler)
{
_pattern = pattern;
_regex = new Regex(pattern, RegexOptions.Compiled);
_regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
}
public override async ValueTask<Directive?> Run(RawSourceFile source)

View File

@ -67,13 +67,13 @@ public class CompilerSettingsInferencer
cs.Include = Array.Empty<RelativePath>();
foreach (var file in mo2Folder.EnumerateFiles())
{
if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_INCLUDE)
if (MatchesVariants(file, Consts.WABBAJACK_INCLUDE))
cs.Include = cs.Include.Add(file.Parent.RelativeTo(mo2Folder));
if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_NOMATCH_INCLUDE)
if (MatchesVariants(file, Consts.WABBAJACK_NOMATCH_INCLUDE))
cs.NoMatchInclude = cs.NoMatchInclude.Add(file.Parent.RelativeTo(mo2Folder));
if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_IGNORE)
if (MatchesVariants(file, Consts.WABBAJACK_IGNORE))
cs.Ignore = cs.Ignore.Add(file.Parent.RelativeTo(mo2Folder));
}
@ -120,4 +120,12 @@ public class CompilerSettingsInferencer
return null;
}
private static bool MatchesVariants(AbsolutePath file, string baseVariant)
{
var withoutExt = file.FileName.WithoutExtension().ToString();
return withoutExt == baseVariant ||
withoutExt == baseVariant + "_FILES";
}
}

View File

@ -292,8 +292,9 @@ public class MO2Compiler : ACompiler
new IgnoreFilename(this, "portable.txt".ToRelativePath()),
new IgnoreExtension(this, Ext.Bin),
new IgnoreFilename(this, ".refcache".ToRelativePath()),
//Include custom categories
new IncludeRegex(this, "categories.dat$"),
//Include custom categories / splash screens
new IncludeRegex(this, @"categories\.dat$"),
new IncludeRegex(this, @"splash\.png"),
new IncludeAllConfigs(this),
// TODO

View File

@ -258,6 +258,7 @@ public static class GameRegistry
Game = Game.StardewValley,
NexusName = "stardewvalley",
MO2Name = "Stardew Valley",
MO2ArchiveName = "stardewvalley",
NexusGameId = 1303,
SteamIDs = new[] {413150},
GOGIDs = new[] {1453375253},

View File

@ -63,6 +63,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
public override async Task<bool> Begin(CancellationToken token)
{
if (token.IsCancellationRequested) return false;
_logger.LogInformation("Installing: {Name} - {Version}", _configuration.ModList.Name, _configuration.ModList.Version);
await _wjClient.SendMetric(MetricNames.BeginInstall, ModList.Name);
NextStep(Consts.StepPreparing, "Configuring Installer", 0);
_logger.LogInformation("Configuring Processor");

View File

@ -1,6 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Wabbajack.Paths;
@ -69,6 +71,18 @@ public struct AbsolutePath : IPath, IComparable<AbsolutePath>, IEquatable<Absolu
public int Depth => Parts?.Length ?? 0;
public IEnumerable<AbsolutePath> ThisAndAllParents()
{
var p = this;
while (true)
{
yield return p;
if (p.Depth == 1)
yield break;
p = p.Parent;
}
}
public AbsolutePath ReplaceExtension(Extension newExtension)
{
var paths = new string[Parts.Length];
@ -126,7 +140,7 @@ public struct AbsolutePath : IPath, IComparable<AbsolutePath>, IEquatable<Absolu
public RelativePath RelativeTo(AbsolutePath basePath)
{
if (!ArrayExtensions.AreEqual(basePath.Parts, 0, Parts, 0, basePath.Parts.Length))
if (!ArrayExtensions.AreEqualIgnoreCase(basePath.Parts, 0, Parts, 0, basePath.Parts.Length))
throw new PathException($"{basePath} is not a base path of {this}");
var newParts = new string[Parts.Length - basePath.Parts.Length];
@ -136,7 +150,7 @@ public struct AbsolutePath : IPath, IComparable<AbsolutePath>, IEquatable<Absolu
public bool InFolder(AbsolutePath parent)
{
return ArrayExtensions.AreEqual(parent.Parts, 0, Parts, 0, parent.Parts.Length);
return ArrayExtensions.AreEqualIgnoreCase(parent.Parts, 0, Parts, 0, parent.Parts.Length);
}
public AbsolutePath Combine(params object[] paths)