mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Fix auto updater creating conflicting RevInfos
This commit is contained in:
@@ -308,19 +308,22 @@ namespace Tgstation.Server.Host.Components
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
Task<RevisionInformation> LoadRevInfo() => databaseContext.RevisionInformations
|
||||
.AsQueryable()
|
||||
.Where(x => x.CommitSha == startSha && x.Instance.Id == metadata.Id)
|
||||
.Include(x => x.ActiveTestMerges).ThenInclude(x => x.TestMerge)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
RevisionInformation currentRevInfo = null;
|
||||
var hasDbChanges = false;
|
||||
RevisionInformation currentRevInfo = null;
|
||||
Models.Instance attachedInstance = null;
|
||||
async Task UpdateRevInfo(string currentHead, bool onOrigin, IEnumerable<RevInfoTestMerge> updatedTestMerges)
|
||||
{
|
||||
if (currentRevInfo == null)
|
||||
currentRevInfo = await LoadRevInfo().ConfigureAwait(false);
|
||||
{
|
||||
logger.LogTrace("Loading revision info for commit {0}...", startSha.Substring(0, 7));
|
||||
currentRevInfo = await databaseContext
|
||||
.RevisionInformations
|
||||
.AsQueryable()
|
||||
.Where(x => x.CommitSha == startSha && x.Instance.Id == metadata.Id)
|
||||
.Include(x => x.ActiveTestMerges)
|
||||
.ThenInclude(x => x.TestMerge)
|
||||
.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (currentRevInfo == default)
|
||||
{
|
||||
@@ -328,6 +331,12 @@ namespace Tgstation.Server.Host.Components
|
||||
onOrigin = true;
|
||||
}
|
||||
|
||||
if (currentRevInfo.CommitSha == currentHead)
|
||||
{
|
||||
logger.LogTrace("Not updating rev-info, already in DB.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (attachedInstance == null)
|
||||
{
|
||||
attachedInstance = new Models.Instance
|
||||
@@ -347,6 +356,7 @@ namespace Tgstation.Server.Host.Components
|
||||
: await repo.GetOriginSha(cancellationToken).ConfigureAwait(false),
|
||||
Instance = attachedInstance,
|
||||
};
|
||||
|
||||
if (!onOrigin)
|
||||
currentRevInfo.ActiveTestMerges = new List<RevInfoTestMerge>(
|
||||
updatedTestMerges ?? oldRevInfo.ActiveTestMerges);
|
||||
|
||||
Reference in New Issue
Block a user