Removed internal WorkQueue in ValidateModlist that was un-disposed

This commit is contained in:
Justin Swanson 2019-12-06 20:05:24 -06:00
parent 03c88b0f38
commit e90759937b
4 changed files with 24 additions and 12 deletions

View File

@ -267,7 +267,7 @@ namespace Wabbajack.Lib
UpdateTracker.NextStep("Running Validation");
ValidateModlist.RunValidation(ModList);
ValidateModlist.RunValidation(Queue, ModList);
UpdateTracker.NextStep("Generating Report");
GenerateReport();

View File

@ -61,7 +61,7 @@ namespace Wabbajack.Lib
if (cancel.IsCancellationRequested) return false;
UpdateTracker.NextStep("Validating Modlist");
ValidateModlist.RunValidation(ModList);
ValidateModlist.RunValidation(Queue, ModList);
Directory.CreateDirectory(OutputFolder);
Directory.CreateDirectory(DownloadFolder);

View File

@ -17,9 +17,14 @@ namespace Wabbajack.Lib.Validation
{
public Dictionary<string, Author> AuthorPermissions { get; set; } = new Dictionary<string, Author>();
private WorkQueue Queue = new WorkQueue();
private readonly WorkQueue _queue;
public ServerWhitelist ServerWhitelist { get; set; } = new ServerWhitelist();
public ValidateModlist(WorkQueue workQueue)
{
_queue = workQueue;
}
public void LoadAuthorPermissionsFromString(string s)
{
AuthorPermissions = s.FromYaml<Dictionary<string, Author>>();
@ -49,9 +54,9 @@ namespace Wabbajack.Lib.Validation
}
public static void RunValidation(ModList modlist)
public static void RunValidation(WorkQueue queue, ModList modlist)
{
var validator = new ValidateModlist();
var validator = new ValidateModlist(queue);
validator.LoadListsFromGithub();
@ -103,12 +108,12 @@ namespace Wabbajack.Lib.Validation
var nexus_mod_permissions = modlist.Archives
.Where(a => a.State is NexusDownloader.State)
.PMap(Queue, a => (a.Hash, FilePermissions((NexusDownloader.State)a.State), a))
.PMap(_queue, a => (a.Hash, FilePermissions((NexusDownloader.State)a.State), a))
.ToDictionary(a => a.Hash, a => new { permissions = a.Item2, archive = a.a });
modlist.Directives
.OfType<PatchedFromArchive>()
.PMap(Queue, p =>
.PMap(_queue, p =>
{
if (nexus_mod_permissions.TryGetValue(p.ArchiveHashPath[0], out var archive))
{
@ -127,7 +132,7 @@ namespace Wabbajack.Lib.Validation
modlist.Directives
.OfType<FromArchive>()
.PMap(Queue,p =>
.PMap(_queue, p =>
{
if (nexus_mod_permissions.TryGetValue(p.ArchiveHashPath[0], out var archive))
{

View File

@ -6,6 +6,7 @@ using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib;
using Wabbajack.Lib.Validation;
using Game = Wabbajack.Common.Game;
using Wabbajack.Common;
namespace Wabbajack.Test
{
@ -47,9 +48,12 @@ namespace Wabbajack.Test
[TestInitialize]
public void TestSetup()
{
validate = new ValidateModlist();
validate.LoadAuthorPermissionsFromString(permissions);
validate.LoadServerWhitelist(server_whitelist);
using (var workQueue = new WorkQueue())
{
validate = new ValidateModlist(workQueue);
validate.LoadAuthorPermissionsFromString(permissions);
validate.LoadServerWhitelist(server_whitelist);
}
}
[TestMethod]
@ -243,7 +247,10 @@ namespace Wabbajack.Test
[TestMethod]
public void CanLoadFromGithub()
{
new ValidateModlist().LoadListsFromGithub();
using (var workQueue = new WorkQueue())
{
new ValidateModlist(workQueue).LoadListsFromGithub();
}
}
}