From 09fdb6e5f134be9ddf358ef54b81a45ffd866a6f Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 18 Sep 2024 18:45:55 +0200 Subject: [PATCH] Fix #250 old jobs getting re-exported. --- Tranga/Jobs/JobBoss.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 91d3870..2e35168 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -191,6 +191,7 @@ public class JobBoss : GlobalBase string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json"); string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile); + //Delete old file if (File.Exists(oldFilePath)) { Log($"Deleting Job-file {oldFilePath}"); @@ -205,12 +206,16 @@ public class JobBoss : GlobalBase Log(e.ToString()); } } - - Log($"Exporting Job {newJobFilePath}"); - string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented); - while(IsFileInUse(newJobFilePath)) - Thread.Sleep(10); - File.WriteAllText(newJobFilePath, jobStr); + + //Export job (in new file) if it is still in our jobs list + if (GetJobById(job.id) is not null) + { + Log($"Exporting Job {newJobFilePath}"); + string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented); + while(IsFileInUse(newJobFilePath)) + Thread.Sleep(10); + File.WriteAllText(newJobFilePath, jobStr); + } } private void UpdateAllJobFiles()