CurrentVersion renamed to NewVersion. No longer returned on Read

This commit is contained in:
Cyberboss
2018-08-20 12:10:58 -04:00
parent 9625567bc6
commit 048dc486d7
4 changed files with 14 additions and 15 deletions
+2
View File
@@ -168,6 +168,8 @@ If you want to perform a live update of the server use
POST "/Administration" @ref Tgstation.Server.Api.Models.Administration => OK
With the @ref Tgstation.Server.Api.Models.Administration.NewVersion field set
Any DreamDaemon servers running will persist while the server installs the new version from the official tgstation-server GitHub (If it exists)
If the server is otherwise acting funky and you wish to restart it, use this request:
@@ -19,7 +19,7 @@ namespace Tgstation.Server.Api.Models
public Uri TrackedRepositoryUrl { get; set; }
/// <summary>
/// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If <see cref="Version.Minor"/> is higher than <see cref="CurrentVersion"/>'s the update cannot be applied due to API changes
/// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If <see cref="Version.Minor"/> is higher than <see cref="NewVersion"/>'s the update cannot be applied due to API changes
/// </summary>
[Permissions(DenyWrite = true)]
public Version LatestVersion { get; set; }
@@ -28,6 +28,6 @@ namespace Tgstation.Server.Api.Models
/// Changes the version of Tgstation.Server.Host to the given version from the upstream repository
/// </summary>
[Permissions(WriteRight = AdministrationRights.ChangeVersion)]
public Version CurrentVersion { get; set; }
public Version NewVersion { get; set; }
}
}
@@ -21,7 +21,7 @@ namespace Tgstation.Server.Api.Rights
/// </summary>
RestartHost = 2,
/// <summary>
/// User can change <see cref="Models.Administration.CurrentVersion"/>
/// User can change <see cref="Models.Administration.NewVersion"/>
/// </summary>
ChangeVersion = 4,
/// <summary>
@@ -90,10 +90,6 @@ namespace Tgstation.Server.Host.Controllers
[TgsAuthorize]
public override async Task<IActionResult> Read(CancellationToken cancellationToken)
{
var model = new Administration
{
CurrentVersion = application.Version
};
try
{
var repositoryTask = gitHubClient.Repository.Get(updatesConfiguration.GitHubRepositoryId);
@@ -105,16 +101,17 @@ namespace Tgstation.Server.Host.Controllers
&& version.Major == application.Version.Major
&& (greatestVersion == null || version > greatestVersion))
greatestVersion = version;
model.LatestVersion = greatestVersion;
model.TrackedRepositoryUrl = new Uri((await repositoryTask.ConfigureAwait(false)).HtmlUrl);
model.WindowsHost = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
return Json(new Administration
{
LatestVersion = greatestVersion,
TrackedRepositoryUrl = new Uri((await repositoryTask.ConfigureAwait(false)).HtmlUrl),
WindowsHost = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
});
}
catch (RateLimitExceededException e)
{
return RateLimit(e);
}
return Json(model);
}
/// <inheritdoc />
@@ -124,10 +121,10 @@ namespace Tgstation.Server.Host.Controllers
if (model == null)
throw new ArgumentNullException(nameof(model));
if (model.CurrentVersion == null)
if (model.NewVersion == null)
return BadRequest(new ErrorMessage { Message = "Missing new version!" });
if (model.CurrentVersion.Major != application.Version.Major)
if (model.NewVersion.Major != application.Version.Major)
return BadRequest(new ErrorMessage { Message = "Cannot update to a different suite version!" });
IEnumerable<Release> releases;
@@ -141,7 +138,7 @@ namespace Tgstation.Server.Host.Controllers
}
foreach (var release in releases)
if (Version.TryParse(release.TagName.Replace(updatesConfiguration.GitTagPrefix, String.Empty, StringComparison.Ordinal), out var version) && version == model.CurrentVersion)
if (Version.TryParse(release.TagName.Replace(updatesConfiguration.GitTagPrefix, String.Empty, StringComparison.Ordinal), out var version) && version == model.NewVersion)
{
var asset = release.Assets.Where(x => x.Name == updatesConfiguration.UpdatePackageAssetName).FirstOrDefault();
if (asset == default)