2
0

Remove filewrites

This commit is contained in:
glax 2023-09-19 23:15:18 +02:00
parent 0875e7ee12
commit b6cdb07e3f

View File

@ -165,11 +165,28 @@ public class JobBoss : GlobalBase
public void ExportJob(Job job)
{
string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json");
string jobStr = JsonConvert.SerializeObject(job);
while(IsFileInUse(jobFilePath))
Thread.Sleep(10);
Log($"Exporting Job {jobFilePath}");
File.WriteAllText(jobFilePath, jobStr);
if (!this.jobs.Any(jjob => jjob.id == job.id))
{
try
{
while(IsFileInUse(jobFilePath))
Thread.Sleep(10);
File.Delete(jobFilePath);
}
catch (Exception e)
{
Log(e.ToString());
}
}
else
{
string jobStr = JsonConvert.SerializeObject(job);
while(IsFileInUse(jobFilePath))
Thread.Sleep(10);
File.WriteAllText(jobFilePath, jobStr);
}
}
public void ExportJobsList()