From eebe25a378091d09db67148027d5acc994dce66b Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 2 Sep 2023 14:46:38 +0200 Subject: [PATCH] Added check if jobQueue is empty --- Tranga/Jobs/JobBoss.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index e803b72..5cfe59f 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -60,11 +60,12 @@ public class JobBoss : GlobalBase File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs)); } - public void RemoveJobs(IEnumerable jobsToRemove) + public void RemoveJobs(IEnumerable jobsToRemove) { Log($"Removing {jobsToRemove.Count()} jobs."); - foreach (Job job in jobsToRemove) - RemoveJob(job); + foreach (Job? job in jobsToRemove) + if(job is not null) + RemoveJob(job); } public IEnumerable GetJobsLike(string? connectorName = null, string? internalId = null, string? chapterNumber = null) @@ -143,6 +144,8 @@ public class JobBoss : GlobalBase AddJobToQueue(job); foreach (Queue jobQueue in mangaConnectorJobQueue.Values) { + if(jobQueue.Count < 1) + continue; Job queueHead = jobQueue.Peek(); if (queueHead.progressToken.state is ProgressToken.State.Complete) {