mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e38d67fee1
@ -0,0 +1,46 @@
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
public class IgnoreGameFilesIfGameFolderFilesExist : ACompilationStep
|
||||
{
|
||||
private readonly bool _gameFolderFilesExists;
|
||||
private readonly string _gameFolder;
|
||||
|
||||
public IgnoreGameFilesIfGameFolderFilesExist(ACompiler compiler) : base(compiler)
|
||||
{
|
||||
_gameFolderFilesExists = Directory.Exists(Path.Combine(((MO2Compiler)compiler).MO2Folder, Consts.GameFolderFilesDir));
|
||||
_gameFolder = compiler.GamePath;
|
||||
}
|
||||
|
||||
public override async ValueTask<Directive> Run(RawSourceFile source)
|
||||
{
|
||||
if (_gameFolderFilesExists)
|
||||
{
|
||||
if (source.AbsolutePath.IsInPath(_gameFolder))
|
||||
{
|
||||
var result = source.EvolveTo<IgnoredDirectly>();
|
||||
result.Reason = $"Ignoring game files because {Consts.GameFolderFilesDir} exists";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override IState GetState()
|
||||
{
|
||||
return new State();
|
||||
}
|
||||
|
||||
public class State : IState
|
||||
{
|
||||
public ICompilationStep CreateStep(ACompiler compiler)
|
||||
{
|
||||
return new IgnoreGameFilesIfGameFolderFilesExist(compiler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -496,6 +496,7 @@ namespace Wabbajack.Lib
|
||||
Utils.Log("Generating compilation stack");
|
||||
return new List<ICompilationStep>
|
||||
{
|
||||
new IgnoreGameFilesIfGameFolderFilesExist(this),
|
||||
new IncludePropertyFiles(this),
|
||||
new IgnoreStartsWith(this,"logs\\"),
|
||||
new IgnoreStartsWith(this, "downloads\\"),
|
||||
|
@ -101,6 +101,7 @@
|
||||
<Compile Include="CompilationSteps\IgnoreDisabledVortexMods.cs" />
|
||||
<Compile Include="CompilationSteps\IgnoreEndsWith.cs" />
|
||||
<Compile Include="CompilationSteps\IgnoreGameFiles.cs" />
|
||||
<Compile Include="CompilationSteps\IgnoreGameFilesIfGameFolderFilesExist.cs" />
|
||||
<Compile Include="CompilationSteps\IgnorePathContains.cs" />
|
||||
<Compile Include="CompilationSteps\IgnoreRegex.cs" />
|
||||
<Compile Include="CompilationSteps\IgnoreStartsWith.cs" />
|
||||
|
@ -32,6 +32,44 @@ namespace Wabbajack.Test
|
||||
|
||||
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestDirectMatchFromGameFolder()
|
||||
{
|
||||
|
||||
var profile = utils.AddProfile();
|
||||
var mod = utils.AddMod();
|
||||
var test_pex = utils.AddGameFile(@"enbstuff\test.pex", 10);
|
||||
|
||||
utils.Configure();
|
||||
|
||||
utils.AddManualDownload(
|
||||
new Dictionary<string, byte[]> {{"/baz/biz.pex", File.ReadAllBytes(test_pex)}});
|
||||
|
||||
await CompileAndInstall(profile);
|
||||
|
||||
utils.VerifyInstalledGameFile(@"enbstuff\test.pex");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestDirectMatchIsIgnoredWhenGameFolderFilesOverrideExists()
|
||||
{
|
||||
|
||||
var profile = utils.AddProfile();
|
||||
var mod = utils.AddMod();
|
||||
var test_pex = utils.AddGameFile(@"enbstuff\test.pex", 10);
|
||||
|
||||
utils.Configure();
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(utils.MO2Folder, Consts.GameFolderFilesDir));
|
||||
|
||||
utils.AddManualDownload(
|
||||
new Dictionary<string, byte[]> {{"/baz/biz.pex", File.ReadAllBytes(test_pex)}});
|
||||
|
||||
await CompileAndInstall(profile);
|
||||
|
||||
Assert.IsFalse(File.Exists(Path.Combine(utils.InstallFolder, Consts.GameFolderFilesDir, @"enbstuff\test.pex")));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestDuplicateFilesAreCopied()
|
||||
|
@ -177,7 +177,26 @@ namespace Wabbajack.Test
|
||||
Assert.Fail($"Index {x} of {mod}\\{file} are not the same");
|
||||
}
|
||||
}
|
||||
|
||||
public void VerifyInstalledGameFile(string file)
|
||||
{
|
||||
var src = Path.Combine(GameFolder, file);
|
||||
Assert.IsTrue(File.Exists(src), src);
|
||||
|
||||
var dest = Path.Combine(InstallFolder, Consts.GameFolderFilesDir, file);
|
||||
Assert.IsTrue(File.Exists(dest), dest);
|
||||
|
||||
var src_data = File.ReadAllBytes(src);
|
||||
var dest_data = File.ReadAllBytes(dest);
|
||||
|
||||
Assert.AreEqual(src_data.Length, dest_data.Length);
|
||||
|
||||
for(int x = 0; x < src_data.Length; x++)
|
||||
{
|
||||
if (src_data[x] != dest_data[x])
|
||||
Assert.Fail($"Index {x} of {Consts.GameFolderFilesDir}\\{file} are not the same");
|
||||
}
|
||||
}
|
||||
public string PathOfInstalledFile(string mod, string file)
|
||||
{
|
||||
return Path.Combine(InstallFolder, "mods", mod, file);
|
||||
@ -218,5 +237,15 @@ namespace Wabbajack.Test
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string AddGameFile(string path, int i)
|
||||
{
|
||||
var full_path = Path.Combine(GameFolder, path);
|
||||
var dir = Path.GetDirectoryName(full_path);
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
GenerateRandomFileData(full_path, i);
|
||||
return full_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user