mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 13:07:07 +01:00
Nullify SessionPersistor
This commit is contained in:
@@ -8,12 +8,11 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Models;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
using Z.EntityFramework.Plus;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -77,8 +76,8 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
|
||||
var dbReattachInfo = new Models.ReattachInformation(reattachInformation.AccessIdentifier)
|
||||
{
|
||||
CompileJobId = reattachInformation.Dmb.CompileJob.Id.Value,
|
||||
InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Id.Value,
|
||||
CompileJobId = reattachInformation.Dmb.CompileJob.Require(x => x.Id),
|
||||
InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Require(x => x.Id),
|
||||
Port = reattachInformation.Port,
|
||||
ProcessId = reattachInformation.ProcessId,
|
||||
RebootState = reattachInformation.RebootState,
|
||||
@@ -89,7 +88,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
db.ReattachInformations.Add(dbReattachInfo);
|
||||
await db.Save(cancellationToken);
|
||||
|
||||
reattachInformation.Id = dbReattachInfo.Id.Value;
|
||||
reattachInformation.Id = dbReattachInfo.Id!.Value;
|
||||
logger.LogDebug("Saved reattach information: {info}", reattachInformation);
|
||||
});
|
||||
|
||||
@@ -110,8 +109,8 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
db.ReattachInformations.Attach(dbReattachInfo);
|
||||
|
||||
dbReattachInfo.AccessIdentifier = reattachInformation.AccessIdentifier;
|
||||
dbReattachInfo.CompileJobId = reattachInformation.Dmb.CompileJob.Id.Value;
|
||||
dbReattachInfo.InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Id.Value;
|
||||
dbReattachInfo.CompileJobId = reattachInformation.Dmb.CompileJob.Require(x => x.Id);
|
||||
dbReattachInfo.InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Require(x => x.Id);
|
||||
dbReattachInfo.Port = reattachInformation.Port;
|
||||
dbReattachInfo.ProcessId = reattachInformation.ProcessId;
|
||||
dbReattachInfo.RebootState = reattachInformation.RebootState;
|
||||
@@ -124,9 +123,9 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
});
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask<ReattachInformation> Load(CancellationToken cancellationToken)
|
||||
public async ValueTask<ReattachInformation?> Load(CancellationToken cancellationToken)
|
||||
{
|
||||
Models.ReattachInformation result = null;
|
||||
Models.ReattachInformation? result = null;
|
||||
TimeSpan? topicTimeout = null;
|
||||
|
||||
async ValueTask KillProcess(Models.ReattachInformation reattachInfo)
|
||||
@@ -160,19 +159,19 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
var dbReattachInfos = await db
|
||||
.ReattachInformations
|
||||
.AsQueryable()
|
||||
.Where(x => x.CompileJob.Job.Instance.Id == metadata.Id)
|
||||
.Where(x => x.CompileJob!.Job.Instance!.Id == metadata.Id)
|
||||
.Include(x => x.CompileJob)
|
||||
.Include(x => x.InitialCompileJob)
|
||||
.ToListAsync(cancellationToken);
|
||||
result = dbReattachInfos.FirstOrDefault();
|
||||
if (result == default)
|
||||
if (result == null)
|
||||
return;
|
||||
|
||||
var timeoutMilliseconds = await db
|
||||
.Instances
|
||||
.AsQueryable()
|
||||
.Where(x => x.Id == metadata.Id)
|
||||
.Select(x => x.DreamDaemonSettings.TopicRequestTimeout)
|
||||
.Select(x => x.DreamDaemonSettings!.TopicRequestTimeout)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
if (timeoutMilliseconds == default)
|
||||
@@ -207,7 +206,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
return null;
|
||||
}
|
||||
|
||||
var dmb = await dmbFactory.FromCompileJob(result.CompileJob, cancellationToken);
|
||||
var dmb = await dmbFactory.FromCompileJob(result!.CompileJob!, cancellationToken);
|
||||
if (dmb == null)
|
||||
{
|
||||
logger.LogError("Unable to reattach! Could not load .dmb!");
|
||||
@@ -225,7 +224,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
return null;
|
||||
}
|
||||
|
||||
IDmbProvider initialDmb = null;
|
||||
IDmbProvider? initialDmb = null;
|
||||
if (result.InitialCompileJob != null)
|
||||
{
|
||||
logger.LogTrace("Loading initial compile job...");
|
||||
@@ -266,7 +265,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
var baseQuery = databaseContext
|
||||
.ReattachInformations
|
||||
.AsQueryable()
|
||||
.Where(x => x.CompileJob.Job.Instance.Id == metadata.Id);
|
||||
.Where(x => x.CompileJob!.Job.Instance!.Id == metadata.Id);
|
||||
|
||||
if (instant)
|
||||
await baseQuery
|
||||
|
||||
Reference in New Issue
Block a user