From 373a47ccbca3173f35f829167787fa3b8ed386be Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 29 Sep 2018 18:50:11 -0400 Subject: [PATCH] FromCompileJob now assures it has the entire object tree loaded Before we relied on the caller to provide it, but the documentation never specified this. It was easier to move the functionality from LoadCompileJob to here. Fixes #749 --- .../Components/Compiler/DmbFactory.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs index 86d6fb1fd7..fea5cf192e 100644 --- a/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Compiler/DmbFactory.cs @@ -125,15 +125,7 @@ namespace Tgstation.Server.Host.Components.Compiler if (job == null) throw new ArgumentNullException(nameof(job)); - CompileJob finalCompileJob = null; - //now load the entire compile job tree - await databaseContextFactory.UseContext(async db => finalCompileJob = await db.CompileJobs.Where(x => x.Id == job.Id) - .Include(x => x.Job).ThenInclude(x => x.StartedBy) - .Include(x => x.RevisionInformation).ThenInclude(x => x.PrimaryTestMerge).ThenInclude(x => x.MergedBy) - .Include(x => x.RevisionInformation).ThenInclude(x => x.ActiveTestMerges).ThenInclude(x => x.TestMerge).ThenInclude(x => x.MergedBy) - .FirstAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false); //can't wait to see that query - - var newProvider = await FromCompileJob(finalCompileJob, cancellationToken).ConfigureAwait(false); + var newProvider = await FromCompileJob(job, cancellationToken).ConfigureAwait(false); if (newProvider == null) return; lock (this) @@ -188,6 +180,14 @@ namespace Tgstation.Server.Host.Components.Compiler { if (compileJob == null) throw new ArgumentNullException(nameof(compileJob)); + + //ensure we have the entire compile job tree + await databaseContextFactory.UseContext(async db => compileJob = await db.CompileJobs.Where(x => x.Id == compileJob.Id) + .Include(x => x.Job).ThenInclude(x => x.StartedBy) + .Include(x => x.RevisionInformation).ThenInclude(x => x.PrimaryTestMerge).ThenInclude(x => x.MergedBy) + .Include(x => x.RevisionInformation).ThenInclude(x => x.ActiveTestMerges).ThenInclude(x => x.TestMerge).ThenInclude(x => x.MergedBy) + .FirstAsync(cancellationToken).ConfigureAwait(false)).ConfigureAwait(false); //can't wait to see that query + logger.LogTrace("Loading compile job {0}...", compileJob.Id); var providerSubmitted = false; var newProvider = new DmbProvider(compileJob, ioManager, () =>