Merge pull request #52 from tr4wzified/properfoldervalidation

Add validation to prevent Wabbajack from crashing when selecting invalid profile directory or starting compilation without specifying profile directory
This commit is contained in:
Timothy Baldridge 2019-09-25 21:38:08 -06:00 committed by GitHub
commit 97c5fbecf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -425,13 +425,15 @@ namespace Wabbajack
if (folder != null)
{
var file = Path.Combine(folder, "modlist.txt");
if (!File.Exists(file))
if(File.Exists(file))
{
Location = file;
ConfigureForBuild();
}
else
{
Utils.Log($"No modlist.txt found at {file}");
}
Location = file;
ConfigureForBuild();
}
}
}
@ -500,32 +502,40 @@ namespace Wabbajack
}
else
{
var compiler = new Compiler(_mo2Folder, msg => LogMsg(msg));
compiler.IgnoreMissingFiles = IgnoreMissingFiles;
compiler.MO2Profile = ModListName;
var th = new Thread(() =>
if (_mo2Folder != null)
{
UIReady = false;
try
var compiler = new Compiler(_mo2Folder, msg => LogMsg(msg));
compiler.IgnoreMissingFiles = IgnoreMissingFiles;
compiler.MO2Profile = ModListName;
var th = new Thread(() =>
{
compiler.Compile();
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
HTMLReport = compiler.ModList.ReportHTML;
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
LogMsg(ex.StackTrace);
LogMsg(ex.ToString());
LogMsg($"{ex.Message} - Can't continue");
}
finally
{
UIReady = true;
}
});
th.Priority = ThreadPriority.BelowNormal;
th.Start();
UIReady = false;
try
{
compiler.Compile();
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
HTMLReport = compiler.ModList.ReportHTML;
}
catch (Exception ex)
{
while (ex.InnerException != null) ex = ex.InnerException;
LogMsg(ex.StackTrace);
LogMsg(ex.ToString());
LogMsg($"{ex.Message} - Can't continue");
}
finally
{
UIReady = true;
}
});
th.Priority = ThreadPriority.BelowNormal;
th.Start();
}
else
{
Utils.Log("Cannot compile modlist: no valid Mod Organizer profile directory selected.");
UIReady = true;
}
}
}