From 51a6f216af029590ab16dc69c71bfc7e42c3b5a2 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 10 Oct 2023 22:51:24 +0200 Subject: [PATCH] Remove extraneous covers from imageCache. --- Tranga/Jobs/JobBoss.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index cd320ed..18ac437 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -162,14 +162,21 @@ public class JobBoss : GlobalBase new JobJsonConverter(this, new MangaConnectorJsonConverter(this, connectors)))!; this.jobs.Add(job); } - + //Connect jobs to parent-jobs and add Publications to cache foreach (Job job in this.jobs) { this.jobs.FirstOrDefault(jjob => jjob.id == job.parentJobId)?.AddSubJob(job); - if(job is DownloadNewChapters dncJob) + if (job is DownloadNewChapters dncJob) cachedPublications.Add(dncJob.manga); } + + HashSet coverFileNames = cachedPublications.Select(manga => manga.coverFileNameInCache!).ToHashSet(); + foreach (string fileName in Directory.GetFiles(settings.coverImageCache)) + { + if(!coverFileNames.Any(existingManga => fileName.Contains(existingManga))) + File.Delete(fileName); + } } private void UpdateJobFile(Job job)