diff --git a/API/Schema/Jobs/DownloadSingleChapterJob.cs b/API/Schema/Jobs/DownloadSingleChapterJob.cs index 9581ae5..0868c9b 100644 --- a/API/Schema/Jobs/DownloadSingleChapterJob.cs +++ b/API/Schema/Jobs/DownloadSingleChapterJob.cs @@ -18,7 +18,7 @@ public class DownloadSingleChapterJob(string chapterId, string? parentJobId = nu public string ChapterId { get; init; } = chapterId; public virtual Chapter Chapter { get; init; } - protected override IEnumerable RunInternal() + protected override IEnumerable RunInternal(PgsqlContext context) { MangaConnector connector = Chapter.ParentManga.MangaConnector; DownloadChapterImages(Chapter); @@ -50,8 +50,6 @@ public class DownloadSingleChapterJob(string chapterId, string? parentJobId = nu //Download all Images to temporary Folder if (imageUrls.Length == 0) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - File.SetUnixFileMode(saveArchiveFilePath, UserRead | UserWrite | UserExecute | GroupRead | GroupWrite | GroupExecute); Directory.Delete(tempFolder, true); return false; } diff --git a/API/Schema/Jobs/Job.cs b/API/Schema/Jobs/Job.cs index bbce2ab..9861800 100644 --- a/API/Schema/Jobs/Job.cs +++ b/API/Schema/Jobs/Job.cs @@ -36,13 +36,13 @@ public abstract class Job NextExecution = LastExecution.AddMilliseconds(RecurrenceMs); } - public IEnumerable Run() + public IEnumerable Run(PgsqlContext context) { this.state = JobState.Running; - IEnumerable newJobs = RunInternal(); + IEnumerable newJobs = RunInternal(context); this.state = JobState.Completed; return newJobs; } - protected abstract IEnumerable RunInternal(); + protected abstract IEnumerable RunInternal(PgsqlContext context); } \ No newline at end of file diff --git a/API/Schema/Jobs/MoveFileOrFolderJob.cs b/API/Schema/Jobs/MoveFileOrFolderJob.cs index 9013b6f..816613b 100644 --- a/API/Schema/Jobs/MoveFileOrFolderJob.cs +++ b/API/Schema/Jobs/MoveFileOrFolderJob.cs @@ -6,7 +6,7 @@ public class MoveFileOrFolderJob(string fromLocation, string toLocation, string? public string FromLocation { get; init; } = fromLocation; public string ToLocation { get; init; } = toLocation; - protected override IEnumerable RunInternal() + protected override IEnumerable RunInternal(PgsqlContext context) { throw new NotImplementedException(); } diff --git a/API/Schema/Jobs/UpdateMetadataJob.cs b/API/Schema/Jobs/UpdateMetadataJob.cs index 792ffa0..c181c82 100644 --- a/API/Schema/Jobs/UpdateMetadataJob.cs +++ b/API/Schema/Jobs/UpdateMetadataJob.cs @@ -9,7 +9,7 @@ public class UpdateMetadataJob(ulong recurrenceMs, string mangaId, string? paren public string MangaId { get; init; } = mangaId; public virtual Manga Manga { get; init; } - protected override IEnumerable RunInternal() + protected override IEnumerable RunInternal(PgsqlContext context) { throw new NotImplementedException(); } diff --git a/API/Tranga.cs b/API/Tranga.cs index dcb7bfd..8d6259c 100644 --- a/API/Tranga.cs +++ b/API/Tranga.cs @@ -63,7 +63,6 @@ public static class Tranga string TRANGA = "\n\n _______ \n|_ _|.----..---.-..-----..-----..---.-.\n | | | _|| _ || || _ || _ |\n |___| |__| |___._||__|__||___ ||___._|\n |_____| \n\n"; Log.Info(TRANGA); - List newJobs = new(); while (true) { List completedJobs = context.Jobs.Where(j => j.state == JobState.Completed).ToList(); @@ -82,14 +81,13 @@ public static class Tranga { Thread t = new (() => { - newJobs.AddRange(job.Run()); + IEnumerable newJobs = job.Run(context); + context.Jobs.AddRange(newJobs); }); RunningJobs.Add(t, job); t.Start(); context.Jobs.Update(job); } - context.Jobs.AddRange(newJobs); - newJobs.Clear(); (Thread, Job)[] removeFromThreadsList = RunningJobs.Where(t => !t.Key.IsAlive) .Select(t => (t.Key, t.Value)).ToArray();