2
0

Do not add duplicate jobs

This commit is contained in:
glax 2023-09-01 22:39:22 +02:00
parent 32036df057
commit c813e1854d

View File

@ -15,8 +15,28 @@ public class JobBoss : GlobalBase
public void AddJob(Job job)
{
Log($"Added {job}");
this.jobs.Add(job);
if (ContainsJobLike(job))
{
Log($"Already Contains Job {job}");
}
else
{
Log($"Added {job}");
this.jobs.Add(job);
}
}
public bool ContainsJobLike(Job job)
{
if (job is DownloadChapter dcJob)
{
return this.GetJobsLike(dcJob.mangaConnector, chapter: dcJob.chapter).Any();
}else if (job is DownloadNewChapters ncJob)
{
return this.GetJobsLike(ncJob.mangaConnector, ncJob.manga).Any();
}
return false;
}
public void RemoveJob(Job job)