From 0f3da4ec818f796a4e013e9c4676df73b73be0d8 Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 2 Sep 2023 14:46:13 +0200 Subject: [PATCH] Added check to read/write jobs.json if file is in use Write jobs.json on change --- Tranga/Jobs/JobBoss.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 39e5c43..e803b72 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -29,6 +29,8 @@ public class JobBoss : GlobalBase { Log($"Added {job}"); this.jobs.Add(job); + while(IsFileInUse(settings.jobsFilePath)) + Thread.Sleep(10); File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs)); } } @@ -53,6 +55,9 @@ public class JobBoss : GlobalBase this.jobs.Remove(job); if(job.subJobs is not null) RemoveJobs(job.subJobs); + while(IsFileInUse(settings.jobsFilePath)) + Thread.Sleep(10); + File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs)); } public void RemoveJobs(IEnumerable jobsToRemove)