Added check if jobQueue is empty

This commit is contained in:
glax 2023-09-02 14:46:38 +02:00
parent 0f3da4ec81
commit eebe25a378

View File

@ -60,11 +60,12 @@ public class JobBoss : GlobalBase
File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs)); File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs));
} }
public void RemoveJobs(IEnumerable<Job> jobsToRemove) public void RemoveJobs(IEnumerable<Job?> jobsToRemove)
{ {
Log($"Removing {jobsToRemove.Count()} jobs."); Log($"Removing {jobsToRemove.Count()} jobs.");
foreach (Job job in jobsToRemove) foreach (Job? job in jobsToRemove)
RemoveJob(job); if(job is not null)
RemoveJob(job);
} }
public IEnumerable<Job> GetJobsLike(string? connectorName = null, string? internalId = null, string? chapterNumber = null) public IEnumerable<Job> GetJobsLike(string? connectorName = null, string? internalId = null, string? chapterNumber = null)
@ -143,6 +144,8 @@ public class JobBoss : GlobalBase
AddJobToQueue(job); AddJobToQueue(job);
foreach (Queue<Job> jobQueue in mangaConnectorJobQueue.Values) foreach (Queue<Job> jobQueue in mangaConnectorJobQueue.Values)
{ {
if(jobQueue.Count < 1)
continue;
Job queueHead = jobQueue.Peek(); Job queueHead = jobQueue.Peek();
if (queueHead.progressToken.state is ProgressToken.State.Complete) if (queueHead.progressToken.state is ProgressToken.State.Complete)
{ {