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");
@ -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))

View File

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

View File

@ -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)