From f36f34f2126c51f51109544508c82e6ad8db93e6 Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 18 Jun 2025 00:23:33 +0200 Subject: [PATCH] We dont need to actually load the MangaConnector to know if two names match. --- API/Tranga.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/API/Tranga.cs b/API/Tranga.cs index f70f623..5fb8ec4 100644 --- a/API/Tranga.cs +++ b/API/Tranga.cs @@ -140,9 +140,9 @@ public static class Tranga List jobsWithoutDownloading = jobsWithoutDependencies.FilterJobsWithoutDownloading(); //Match running and waiting jobs per Connector - Dictionary>> runningJobsPerConnector = + Dictionary>> runningJobsPerConnector = runningJobs.GetJobsPerJobTypeAndConnector(); - Dictionary>> waitingJobsPerConnector = + Dictionary>> waitingJobsPerConnector = jobsWithoutDependencies.GetJobsPerJobTypeAndConnector(); List jobsNotHeldBackByConnector = MatchJobsRunningAndWaiting(runningJobsPerConnector, waitingJobsPerConnector); @@ -250,13 +250,13 @@ public static class Tranga } - private static Dictionary>> GetJobsPerJobTypeAndConnector(this List jobs) + private static Dictionary>> GetJobsPerJobTypeAndConnector(this List jobs) { DateTime start = DateTime.UtcNow; - Dictionary>> ret = new(); + Dictionary>> ret = new(); foreach (Job job in jobs) { - if(GetJobConnector(job) is not { } connector) + if(GetJobConnectorName(job) is not { } connector) continue; if (!ret.ContainsKey(connector)) ret.Add(connector, new()); @@ -269,12 +269,12 @@ public static class Tranga return ret; } - private static List MatchJobsRunningAndWaiting(Dictionary>> running, - Dictionary>> waiting) + private static List MatchJobsRunningAndWaiting(Dictionary>> running, + Dictionary>> waiting) { DateTime start = DateTime.UtcNow; List ret = new(); - foreach ((MangaConnector connector, Dictionary> jobTypeJobsWaiting) in waiting) + foreach ((string connector, Dictionary> jobTypeJobsWaiting) in waiting) { if (running.TryGetValue(connector, out Dictionary>? jobTypeJobsRunning)) { //MangaConnector has running Jobs @@ -309,17 +309,18 @@ public static class Tranga Log.Debug($"Getting eligible jobs (not held back by Connector) took {end.Subtract(start).TotalMilliseconds}ms"); return ret; } - - private static MangaConnector? GetJobConnector(Job job) + + + private static string? GetJobConnectorName(Job job) { if (job is DownloadAvailableChaptersJob dacj) - return dacj.Manga.MangaConnector; + return dacj.Manga.MangaConnectorName; if (job is DownloadMangaCoverJob dmcj) - return dmcj.Manga.MangaConnector; + return dmcj.Manga.MangaConnectorName; if (job is DownloadSingleChapterJob dscj) - return dscj.Chapter.ParentManga.MangaConnector; + return dscj.Chapter.ParentManga.MangaConnectorName; if (job is RetrieveChaptersJob rcj) - return rcj.Manga.MangaConnector; + return rcj.Manga.MangaConnectorName; return null; } } \ No newline at end of file