Compare commits
No commits in common. "ce1c4d3f651acada4cd1881483dfe7df7e9c4c20" and "f89aea6ac8ee5cfeee9e3272ea0f46dea99843a6" have entirely different histories.
ce1c4d3f65
...
f89aea6ac8
@ -163,7 +163,6 @@ public class JobBoss : GlobalBase
|
|||||||
{
|
{
|
||||||
Log($"Adding Job {job}");
|
Log($"Adding Job {job}");
|
||||||
this.jobs.Add(job);
|
this.jobs.Add(job);
|
||||||
UpdateJobFile(job, file.Name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,23 +188,23 @@ public class JobBoss : GlobalBase
|
|||||||
internal void UpdateJobFile(Job job, string? oldFile = null)
|
internal void UpdateJobFile(Job job, string? oldFile = null)
|
||||||
{
|
{
|
||||||
string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json");
|
string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json");
|
||||||
string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile);
|
|
||||||
|
|
||||||
if (File.Exists(oldFilePath))
|
if (!this.jobs.Any(jjob => jjob.id == job.id))
|
||||||
{
|
{
|
||||||
Log($"Deleting Job-file {oldFilePath}");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while(IsFileInUse(oldFilePath))
|
Log($"Deleting Job-file {newJobFilePath}");
|
||||||
|
while(IsFileInUse(newJobFilePath))
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
File.Delete(oldFilePath);
|
File.Delete(newJobFilePath);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log(e.ToString());
|
Log(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Log($"Exporting Job {newJobFilePath}");
|
Log($"Exporting Job {newJobFilePath}");
|
||||||
string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented);
|
string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented);
|
||||||
while(IsFileInUse(newJobFilePath))
|
while(IsFileInUse(newJobFilePath))
|
||||||
@ -213,6 +212,20 @@ public class JobBoss : GlobalBase
|
|||||||
File.WriteAllText(newJobFilePath, jobStr);
|
File.WriteAllText(newJobFilePath, jobStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(oldFile is not null)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Log($"Deleting old Job-file {oldFile}");
|
||||||
|
while(IsFileInUse(oldFile))
|
||||||
|
Thread.Sleep(10);
|
||||||
|
File.Delete(oldFile);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateAllJobFiles()
|
private void UpdateAllJobFiles()
|
||||||
{
|
{
|
||||||
Log("Exporting Jobs");
|
Log("Exporting Jobs");
|
||||||
|
Loading…
Reference in New Issue
Block a user