diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 99670b4..4380497 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -171,7 +171,7 @@ public class JobBoss : GlobalBase } } - private void UpdateJobFile(Job job) + internal void UpdateJobFile(Job job) { string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json"); @@ -245,7 +245,9 @@ public class JobBoss : GlobalBase 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(this).ToArray(); + Job eJob = jobQueue.Peek(); + Job[] subJobs = eJob.ExecuteReturnSubTasks(this).ToArray(); + UpdateJobFile(eJob); AddJobs(subJobs); AddJobsToQueue(subJobs); }else if (queueHead.progressToken.state is ProgressToken.State.Running && DateTime.Now.Subtract(queueHead.progressToken.lastUpdate) > TimeSpan.FromMinutes(5)) diff --git a/Tranga/Jobs/UpdateMetadata.cs b/Tranga/Jobs/UpdateMetadata.cs index e9107ce..5471685 100644 --- a/Tranga/Jobs/UpdateMetadata.cs +++ b/Tranga/Jobs/UpdateMetadata.cs @@ -33,7 +33,7 @@ public class UpdateMetadata : Job return Array.Empty(); } - this.manga.UpdateMetadata(updatedManga); + this.manga = manga.WithMetadata(updatedManga); this.manga.SaveSeriesInfoJson(settings.downloadLocation, true); this.progressToken.Complete(); } diff --git a/Tranga/Manga.cs b/Tranga/Manga.cs index 32ea54b..388d02d 100644 --- a/Tranga/Manga.cs +++ b/Tranga/Manga.cs @@ -75,18 +75,21 @@ public struct Manga this.websiteUrl = websiteUrl; } - public void UpdateMetadata(Manga newManga) + public Manga WithMetadata(Manga newManga) { - this.sortName = newManga.sortName; - this.description = newManga.description; - this.coverUrl = newManga.coverUrl; - this.authors = authors.Union(newManga.authors).ToList(); - this.altTitles = altTitles.UnionBy(newManga.altTitles, kv => kv.Key).ToDictionary(x => x.Key, x => x.Value); - this.tags = tags.Union(newManga.tags).ToArray(); - this.status = newManga.status; - this.releaseStatus = newManga.releaseStatus; - this.websiteUrl = newManga.websiteUrl; - this.year = newManga.year; + return this with + { + sortName = newManga.sortName, + description = newManga.description, + coverUrl = newManga.coverUrl, + authors = authors.Union(newManga.authors).ToList(), + altTitles = altTitles.UnionBy(newManga.altTitles, kv => kv.Key).ToDictionary(x => x.Key, x => x.Value), + tags = tags.Union(newManga.tags).ToArray(), + status = newManga.status, + releaseStatus = newManga.releaseStatus, + websiteUrl = newManga.websiteUrl, + year = newManga.year + }; } public override bool Equals(object? obj)