Refractored the creation of meta files and fixed downloads being included in the modlist

This commit is contained in:
erri120 2019-11-11 14:03:48 +01:00 committed by Timothy Baldridge
parent 05791f363b
commit fa18a45ebc
3 changed files with 46 additions and 3 deletions

View File

@ -0,0 +1,40 @@
using System;
using System.IO;
using Newtonsoft.Json;
using Wabbajack.Common;
namespace Wabbajack.Lib.CompilationSteps
{
public class IgnoreVortex : ACompilationStep
{
private readonly VortexCompiler _vortex;
public IgnoreVortex(ACompiler compiler) : base(compiler)
{
_vortex = compiler._vortexCompiler;
}
public override Directive Run(RawSourceFile source)
{
if (Path.GetDirectoryName(source.AbsolutePath) != _vortex.DownloadsFolder) return null;
var result = source.EvolveTo<IgnoredDirectly>();
result.Reason = "Ignored because it is a Vortex file";
return result;
}
public override IState GetState()
{
return new State();
}
[JsonObject("IgnoreVortex")]
public class State : IState
{
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IgnoreVortex(compiler);
}
}
}
}

View File

@ -308,8 +308,11 @@ namespace Wabbajack.Lib
private void CreateMetaFiles()
{
Utils.Log("Getting Nexus api_key, please click authorize if a browser window appears");
var nexusClient = new NexusApiClient();
Directory.EnumerateFiles(DownloadsFolder, "*", SearchOption.TopDirectoryOnly)
.Where(f => File.Exists(f) && (Path.GetExtension(f) == ".zip" || Path.GetExtension(f) == ".rar") && !File.Exists(f+".meta"))
.Where(f => File.Exists(f) && Path.GetExtension(f) != ".meta" && !File.Exists(f+".meta"))
.Do(f =>
{
Utils.Log($"Trying to create meta file for {Path.GetFileName(f)}");
@ -320,8 +323,6 @@ namespace Wabbajack.Lib
$"paused=false\n" +
$"removed=false\n" +
$"gameName={GameName}\n";
Utils.Log("Getting Nexus api_key, please click authorize if a browser window appears");
var nexusClient = new NexusApiClient();
string hash;
using(var md5 = MD5.Create())
using (var stream = File.OpenRead(f))
@ -429,6 +430,7 @@ namespace Wabbajack.Lib
//new IncludePropertyFiles(this),
new IncludeVortexDeployment(this),
new IncludeRegex(this, "^*\\.meta"),
new IgnoreVortex(this),
Game == Game.DarkestDungeon ? new IncludeRegex(this, "project\\.xml$") : null,

View File

@ -89,6 +89,7 @@
<Compile Include="CompilationSteps\IgnorePathContains.cs" />
<Compile Include="CompilationSteps\IgnoreRegex.cs" />
<Compile Include="CompilationSteps\IgnoreStartsWith.cs" />
<Compile Include="CompilationSteps\IgnoreVortex.cs" />
<Compile Include="CompilationSteps\IgnoreWabbajackInstallCruft.cs" />
<Compile Include="CompilationSteps\IncludeAll.cs" />
<Compile Include="CompilationSteps\IncludeAllConfigs.cs" />