cuttingedge #57

Merged
glax merged 22 commits from cuttingedge into master 2023-10-10 21:21:35 +02:00
Showing only changes of commit 4156365b18 - Show all commits

View File

@ -37,6 +37,10 @@ public class JobBoss : GlobalBase
AddJob(job); AddJob(job);
} }
/// <summary>
/// Compares contents of the provided job and all current jobs
/// Does not check if objects are the same
/// </summary>
public bool ContainsJobLike(Job job) public bool ContainsJobLike(Job job)
{ {
if (job is DownloadChapter dcJob) if (job is DownloadChapter dcJob)
@ -123,17 +127,16 @@ public class JobBoss : GlobalBase
private bool QueueContainsJob(Job job) private bool QueueContainsJob(Job job)
{ {
mangaConnectorJobQueue.TryAdd(job.mangaConnector, new Queue<Job>()); if (mangaConnectorJobQueue.TryAdd(job.mangaConnector, new Queue<Job>()))//If we can add the queue, there is certainly no job in it
return true;
return mangaConnectorJobQueue[job.mangaConnector].Contains(job); return mangaConnectorJobQueue[job.mangaConnector].Contains(job);
} }
public void AddJobToQueue(Job job) public void AddJobToQueue(Job job)
{ {
Log($"Adding Job to Queue. {job}"); Log($"Adding Job to Queue. {job}");
mangaConnectorJobQueue.TryAdd(job.mangaConnector, new Queue<Job>()); if(!QueueContainsJob(job))
Queue<Job> connectorJobQueue = mangaConnectorJobQueue[job.mangaConnector]; mangaConnectorJobQueue[job.mangaConnector].Enqueue(job);
if(!connectorJobQueue.Contains(job))
connectorJobQueue.Enqueue(job);
job.ExecutionEnqueue(); job.ExecutionEnqueue();
} }