2
0

Added check to read/write jobs.json if file is in use

Write jobs.json on change
This commit is contained in:
glax 2023-09-02 14:46:13 +02:00
parent 0b77dc1172
commit 0f3da4ec81

View File

@ -29,6 +29,8 @@ public class JobBoss : GlobalBase
{ {
Log($"Added {job}"); Log($"Added {job}");
this.jobs.Add(job); this.jobs.Add(job);
while(IsFileInUse(settings.jobsFilePath))
Thread.Sleep(10);
File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs)); File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs));
} }
} }
@ -53,6 +55,9 @@ public class JobBoss : GlobalBase
this.jobs.Remove(job); this.jobs.Remove(job);
if(job.subJobs is not null) if(job.subJobs is not null)
RemoveJobs(job.subJobs); RemoveJobs(job.subJobs);
while(IsFileInUse(settings.jobsFilePath))
Thread.Sleep(10);
File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs));
} }
public void RemoveJobs(IEnumerable<Job> jobsToRemove) public void RemoveJobs(IEnumerable<Job> jobsToRemove)