From 19ff3f578a6b5ef55670b6479878da69c7fcd3e6 Mon Sep 17 00:00:00 2001 From: Glax Date: Thu, 13 Mar 2025 20:06:46 +0100 Subject: [PATCH] Move adding jobs to context to Job.Run (from Tranga.cs) --- API/Schema/Jobs/Job.cs | 3 ++- API/Tranga.cs | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/API/Schema/Jobs/Job.cs b/API/Schema/Jobs/Job.cs index a5ed51b..cf22541 100644 --- a/API/Schema/Jobs/Job.cs +++ b/API/Schema/Jobs/Job.cs @@ -58,8 +58,9 @@ public abstract class Job this.state = JobState.Running; context.SaveChanges(); - IEnumerable newJobs = RunInternal(context); + Job[] newJobs = RunInternal(context).ToArray(); this.state = JobState.Completed; + context.Jobs.AddRange(newJobs); context.SaveChanges(); return newJobs; } diff --git a/API/Tranga.cs b/API/Tranga.cs index 3f30222..f833c40 100644 --- a/API/Tranga.cs +++ b/API/Tranga.cs @@ -113,7 +113,6 @@ public static class Tranga Thread t = new(() => { IEnumerable newJobs = job.Run(serviceProvider); - context.Jobs.AddRange(newJobs); }); RunningJobs.Add(t, job); t.Start();