Skip to content

Commit

Permalink
Fix loading file results in "null"-job and crashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
C9Glax committed May 26, 2024
1 parent 1d44b6d commit f499665
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Tranga/Jobs/JobBoss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,19 @@ private void LoadJobsList(HashSet<MangaConnector> connectors)
foreach (FileInfo file in new DirectoryInfo(settings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name)))
{
Log($"Adding {file.Name}");
Job job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName),
new JobJsonConverter(this, new MangaConnectorJsonConverter(this, connectors)))!;
Log($"Adding Job {job}");
this.jobs.Add(job);
Job? job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName),
new JobJsonConverter(this, new MangaConnectorJsonConverter(this, connectors)));
if (job is null)
{
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
Expand Down

0 comments on commit f499665

Please sign in to comment.