mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 21:16:52 +01:00
Nullify AdministrationController
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Tgstation.Server.Api.Models.Response
|
||||
/// <param name="newVersion">The value of <see cref="NewVersion"/>.</param>
|
||||
/// <param name="fileTicket">The optional value of <see cref="FileTicketResponse.FileTicket"/>.</param>
|
||||
[JsonConstructor]
|
||||
public ServerUpdateResponse(Version newVersion, string fileTicket)
|
||||
public ServerUpdateResponse(Version newVersion, string? fileTicket)
|
||||
{
|
||||
NewVersion = newVersion ?? throw new ArgumentNullException(nameof(newVersion));
|
||||
FileTicket = fileTicket;
|
||||
|
||||
@@ -29,8 +29,6 @@ using Tgstation.Server.Host.Transfer;
|
||||
using Tgstation.Server.Host.Utils;
|
||||
using Tgstation.Server.Host.Utils.GitHub;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Tgstation.Server.Host.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
@@ -146,8 +144,8 @@ namespace Tgstation.Server.Host.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
Version greatestVersion = null;
|
||||
Uri repoUrl = null;
|
||||
Version? greatestVersion = null;
|
||||
Uri? repoUrl = null;
|
||||
try
|
||||
{
|
||||
var gitHubService = gitHubServiceFactory.CreateService();
|
||||
@@ -215,10 +213,10 @@ namespace Tgstation.Server.Host.Controllers
|
||||
var attemptingUpload = model.UploadZip == true;
|
||||
if (attemptingUpload)
|
||||
{
|
||||
if (!AuthenticationContext.PermissionSet.AdministrationRights.Value.HasFlag(AdministrationRights.UploadVersion))
|
||||
if (!AuthenticationContext.PermissionSet.AdministrationRights!.Value.HasFlag(AdministrationRights.UploadVersion))
|
||||
return Forbid();
|
||||
}
|
||||
else if (!AuthenticationContext.PermissionSet.AdministrationRights.Value.HasFlag(AdministrationRights.ChangeVersion))
|
||||
else if (!AuthenticationContext.PermissionSet.AdministrationRights!.Value.HasFlag(AdministrationRights.ChangeVersion))
|
||||
return Forbid();
|
||||
|
||||
if (model.NewVersion == null)
|
||||
@@ -379,7 +377,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in the <see cref="IActionResult"/> of the request.</returns>
|
||||
async ValueTask<IActionResult> AttemptInitiateUpdate(Version newVersion, bool attemptingUpload, CancellationToken cancellationToken)
|
||||
{
|
||||
IFileUploadTicket uploadTicket = attemptingUpload
|
||||
IFileUploadTicket? uploadTicket = attemptingUpload
|
||||
? fileTransferService.CreateUpload(FileUploadStreamKind.None)
|
||||
: null;
|
||||
|
||||
@@ -393,7 +391,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
catch
|
||||
{
|
||||
if (attemptingUpload)
|
||||
await uploadTicket.DisposeAsync();
|
||||
await uploadTicket!.DisposeAsync();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user