2
0

Remove log clutter and filewrites

This commit is contained in:
glax 2023-09-19 20:02:56 +02:00
parent c1aa4cf6b5
commit 87ea077281

View File

@ -161,10 +161,7 @@ public class JobBoss : GlobalBase
cachedPublications.Add(ncJob.manga);
}
public void ExportJobsList()
{
Log("Exporting Jobs");
foreach (Job job in this.jobs)
public void ExportJob(Job job)
{
string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json");
string jobStr = JsonConvert.SerializeObject(job);
@ -174,6 +171,12 @@ public class JobBoss : GlobalBase
File.WriteAllText(jobFilePath, jobStr);
}
public void ExportJobsList()
{
Log("Exporting Jobs");
foreach (Job job in this.jobs)
ExportJob(job);
//Remove files with jobs not in this.jobs-list
Regex idRex = new (@"(.*)\.json");
foreach (FileInfo file in new DirectoryInfo(settings.jobsFolderPath).EnumerateFiles())
@ -219,14 +222,13 @@ public class JobBoss : GlobalBase
}
queueHead.ResetProgress();
jobQueue.Dequeue();
ExportJobsList();
ExportJob(queueHead);
Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}");
}else if (queueHead.progressToken.state is ProgressToken.State.Standby)
{
Job[] subJobs = jobQueue.Peek().ExecuteReturnSubTasks().ToArray();
AddJobs(subJobs);
AddJobsToQueue(subJobs);
ExportJobsList();
}
}
}