2
0

Fix loading file results in "null"-job and crashes.

This commit is contained in:
Glax 2024-05-26 18:22:51 +02:00
parent 1d44b6d9c6
commit f4996659ef

View File

@ -151,10 +151,19 @@ public class JobBoss : GlobalBase
foreach (FileInfo file in new DirectoryInfo(settings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name))) foreach (FileInfo file in new DirectoryInfo(settings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name)))
{ {
Log($"Adding {file.Name}"); Log($"Adding {file.Name}");
Job job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName), Job? job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName),
new JobJsonConverter(this, new MangaConnectorJsonConverter(this, connectors)))!; new JobJsonConverter(this, new MangaConnectorJsonConverter(this, connectors)));
Log($"Adding Job {job}"); if (job is null)
this.jobs.Add(job); {
string newName = file.FullName + ".failed";
Log($"Failed loading file {file.Name}.\nMoving to {newName}");
File.Move(file.FullName, newName);
}
else
{
Log($"Adding Job {job}");
this.jobs.Add(job);
}
} }
//Connect jobs to parent-jobs and add Publications to cache //Connect jobs to parent-jobs and add Publications to cache