Delete duplicate files on startup.
This commit is contained in:
parent
4b88cdbd90
commit
067497ddd0
@ -17,18 +17,21 @@ public class JobBoss : GlobalBase
|
|||||||
Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}");
|
Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddJob(Job job)
|
public bool AddJob(Job job, string? jobFile = null)
|
||||||
{
|
{
|
||||||
if (ContainsJobLike(job))
|
if (ContainsJobLike(job))
|
||||||
{
|
{
|
||||||
Log($"Already Contains Job {job}");
|
Log($"Already Contains Job {job}");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log($"Added {job}");
|
Log($"Added {job}");
|
||||||
this.jobs.Add(job);
|
if (!this.jobs.Add(job))
|
||||||
UpdateJobFile(job);
|
return false;
|
||||||
|
UpdateJobFile(job, jobFile);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddJobs(IEnumerable<Job> jobsToAdd)
|
public void AddJobs(IEnumerable<Job> jobsToAdd)
|
||||||
@ -162,8 +165,8 @@ public class JobBoss : GlobalBase
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log($"Adding Job {job}");
|
Log($"Adding Job {job}");
|
||||||
this.jobs.Add(job);
|
if(!AddJob(job, file.Name)) //If we detect a duplicate, delete the file.
|
||||||
UpdateJobFile(job, file.Name);
|
file.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user