mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 22:17:51 +01:00
Nullify IConfiguration
This commit is contained in:
@@ -8,8 +8,6 @@ using Tgstation.Server.Api.Models.Response;
|
||||
using Tgstation.Server.Host.Components.Events;
|
||||
using Tgstation.Server.Host.Security;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
{
|
||||
/// <summary>
|
||||
@@ -24,7 +22,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// <param name="destination">Path to the destination folder.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in the <see cref="ServerSideModifications"/> if any.</returns>
|
||||
ValueTask<ServerSideModifications> CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken);
|
||||
ValueTask<ServerSideModifications?> CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Symlinks all directories in the GameData directory to <paramref name="destination"/>.
|
||||
@@ -41,7 +39,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// <param name="systemIdentity">The <see cref="ISystemIdentity"/> for the operation. If <see langword="null"/>, the operation will be performed as the user of the <see cref="Core.Application"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in an <see cref="IOrderedQueryable{T}"/> of the <see cref="ConfigurationFileResponse"/>s for the items in the directory. <see cref="FileTicketResponse.FileTicket"/> and <see cref="IConfigurationFile.LastReadHash"/> will both be <see langword="null"/>. <see langword="null"/> will be returned if the operation failed due to access contention.</returns>
|
||||
ValueTask<IOrderedQueryable<ConfigurationFileResponse>> ListDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken);
|
||||
ValueTask<IOrderedQueryable<ConfigurationFileResponse>> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a given <paramref name="configurationRelativePath"/>.
|
||||
@@ -50,7 +48,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// <param name="systemIdentity">The <see cref="ISystemIdentity"/> for the operation. If <see langword="null"/>, the operation will be performed as the user of the <see cref="Core.Application"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in the <see cref="ConfigurationFileResponse"/> of the file. <see langword="null"/> will be returned if the operation failed due to access contention.</returns>
|
||||
ValueTask<ConfigurationFileResponse> Read(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken);
|
||||
ValueTask<ConfigurationFileResponse?> Read(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Create an empty directory at <paramref name="configurationRelativePath"/>.
|
||||
@@ -59,7 +57,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// <param name="systemIdentity">The <see cref="ISystemIdentity"/> for the operation. If <see langword="null"/>, the operation will be performed as the user of the <see cref="Core.Application"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation. Usage may result in partial writes.</param>
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in <see langword="true"/> if the directory already existed, <see langword="false"/> otherwise. <see langword="null"/> will be returned if the operation failed due to access contention.</returns>
|
||||
ValueTask<bool?> CreateDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken);
|
||||
ValueTask<bool?> CreateDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to delete an empty directory at <paramref name="configurationRelativePath"/>.
|
||||
@@ -68,7 +66,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// <param name="systemIdentity">The <see cref="ISystemIdentity"/> for the operation. If <see langword="null"/>, the operation will be performed as the user of the <see cref="Core.Application"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in <see langword="true"/> if the directory was empty and deleted, <see langword="false"/> otherwise. <see langword="null"/> will be returned if the operation failed due to access contention.</returns>
|
||||
ValueTask<bool?> DeleteDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken);
|
||||
ValueTask<bool?> DeleteDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Writes to a given <paramref name="configurationRelativePath"/>.
|
||||
@@ -78,6 +76,6 @@ namespace Tgstation.Server.Host.Components.StaticFiles
|
||||
/// <param name="previousHash">The hash any existing file must match in order for the write to succeed.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation. Usage may result in partial writes.</param>
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in the updated <see cref="ConfigurationFileResponse"/> and associated writing <see cref="FileTicketResponse"/>. <see langword="null"/> will be returned if the operation failed due to access contention.</returns>
|
||||
ValueTask<ConfigurationFileResponse> Write(string configurationRelativePath, ISystemIdentity systemIdentity, string previousHash, CancellationToken cancellationToken);
|
||||
ValueTask<ConfigurationFileResponse?> Write(string configurationRelativePath, ISystemIdentity? systemIdentity, string? previousHash, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
var newFile = await instance
|
||||
.Configuration
|
||||
.Write(
|
||||
model.Path,
|
||||
model.Path!,
|
||||
systemIdentity,
|
||||
model.LastReadHash,
|
||||
cancellationToken);
|
||||
@@ -240,6 +240,9 @@ namespace Tgstation.Server.Host.Controllers
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(model);
|
||||
|
||||
if (model.Path == null)
|
||||
return BadRequest(new ErrorMessageResponse(ErrorCode.ModelValidationFailure));
|
||||
|
||||
if (ForbidDueToModeConflicts(model.Path, out var systemIdentity))
|
||||
return Forbid();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user