2
0

Export Jobfiles after execution, update metadata in jobfiles

This commit is contained in:
Glax 2024-04-22 22:29:22 +02:00
parent 06fe98323a
commit 79e61a62c7
3 changed files with 19 additions and 14 deletions

View File

@ -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"); 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}"); 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) }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); AddJobs(subJobs);
AddJobsToQueue(subJobs); AddJobsToQueue(subJobs);
}else if (queueHead.progressToken.state is ProgressToken.State.Running && DateTime.Now.Subtract(queueHead.progressToken.lastUpdate) > TimeSpan.FromMinutes(5)) }else if (queueHead.progressToken.state is ProgressToken.State.Running && DateTime.Now.Subtract(queueHead.progressToken.lastUpdate) > TimeSpan.FromMinutes(5))

View File

@ -33,7 +33,7 @@ public class UpdateMetadata : Job
return Array.Empty<Job>(); return Array.Empty<Job>();
} }
this.manga.UpdateMetadata(updatedManga); this.manga = manga.WithMetadata(updatedManga);
this.manga.SaveSeriesInfoJson(settings.downloadLocation, true); this.manga.SaveSeriesInfoJson(settings.downloadLocation, true);
this.progressToken.Complete(); this.progressToken.Complete();
} }

View File

@ -75,18 +75,21 @@ public struct Manga
this.websiteUrl = websiteUrl; this.websiteUrl = websiteUrl;
} }
public void UpdateMetadata(Manga newManga) public Manga WithMetadata(Manga newManga)
{ {
this.sortName = newManga.sortName; return this with
this.description = newManga.description; {
this.coverUrl = newManga.coverUrl; sortName = newManga.sortName,
this.authors = authors.Union(newManga.authors).ToList(); description = newManga.description,
this.altTitles = altTitles.UnionBy(newManga.altTitles, kv => kv.Key).ToDictionary(x => x.Key, x => x.Value); coverUrl = newManga.coverUrl,
this.tags = tags.Union(newManga.tags).ToArray(); authors = authors.Union(newManga.authors).ToList(),
this.status = newManga.status; altTitles = altTitles.UnionBy(newManga.altTitles, kv => kv.Key).ToDictionary(x => x.Key, x => x.Value),
this.releaseStatus = newManga.releaseStatus; tags = tags.Union(newManga.tags).ToArray(),
this.websiteUrl = newManga.websiteUrl; status = newManga.status,
this.year = newManga.year; releaseStatus = newManga.releaseStatus,
websiteUrl = newManga.websiteUrl,
year = newManga.year
};
} }
public override bool Equals(object? obj) public override bool Equals(object? obj)