mirror of
https://github.com/C9Glax/tranga.git
synced 2025-07-04 01:44:17 +02:00
Added import and export for Jobs
Renamed tasksFilePath -> jobsFilePath and changed to jobs.json
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Tranga.MangaConnectors;
|
||||
using Newtonsoft.Json;
|
||||
using Tranga.MangaConnectors;
|
||||
|
||||
namespace Tranga.Jobs;
|
||||
|
||||
@ -7,9 +8,12 @@ public class JobBoss : GlobalBase
|
||||
public HashSet<Job> jobs { get; init; }
|
||||
private Dictionary<MangaConnector, Queue<Job>> mangaConnectorJobQueue { get; init; }
|
||||
|
||||
public JobBoss(GlobalBase clone) : base(clone)
|
||||
public JobBoss(GlobalBase clone, HashSet<MangaConnector> connectors) : base(clone)
|
||||
{
|
||||
this.jobs = new();
|
||||
if (File.Exists(settings.jobsFilePath))
|
||||
this.jobs = JsonConvert.DeserializeObject<HashSet<Job>>(File.ReadAllText(settings.jobsFilePath), new JobJsonConverter(this, new MangaConnectorJsonConverter(this, connectors)))!;
|
||||
else
|
||||
this.jobs = new();
|
||||
this.mangaConnectorJobQueue = new();
|
||||
}
|
||||
|
||||
@ -23,6 +27,7 @@ public class JobBoss : GlobalBase
|
||||
{
|
||||
Log($"Added {job}");
|
||||
this.jobs.Add(job);
|
||||
File.WriteAllText(settings.jobsFilePath, JsonConvert.SerializeObject(this.jobs));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user