diff --git a/docs/API.dox b/docs/API.dox index a7be584e94..1407bc59a4 100644 --- a/docs/API.dox +++ b/docs/API.dox @@ -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: diff --git a/src/Tgstation.Server.Api/Models/Administration.cs b/src/Tgstation.Server.Api/Models/Administration.cs index 7c8873d04b..33f7aa5e5f 100644 --- a/src/Tgstation.Server.Api/Models/Administration.cs +++ b/src/Tgstation.Server.Api/Models/Administration.cs @@ -19,7 +19,7 @@ namespace Tgstation.Server.Api.Models public Uri TrackedRepositoryUrl { get; set; } /// - /// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If is higher than '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 is higher than 's the update cannot be applied due to API changes /// [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 /// [Permissions(WriteRight = AdministrationRights.ChangeVersion)] - public Version CurrentVersion { get; set; } + public Version NewVersion { get; set; } } } diff --git a/src/Tgstation.Server.Api/Rights/AdministrationRights.cs b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs index dc8c6f9dfa..6f546020aa 100644 --- a/src/Tgstation.Server.Api/Rights/AdministrationRights.cs +++ b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs @@ -21,7 +21,7 @@ namespace Tgstation.Server.Api.Rights /// RestartHost = 2, /// - /// User can change + /// User can change /// ChangeVersion = 4, /// diff --git a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs index 45aadcca9a..3c438ca6d1 100644 --- a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs +++ b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs @@ -90,10 +90,6 @@ namespace Tgstation.Server.Host.Controllers [TgsAuthorize] public override async Task 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); } /// @@ -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 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)