diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index 3644f20991..b2e12d1947 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -23,8 +23,6 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.StaticFiles { /// @@ -80,7 +78,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles eventType => new KeyValuePair>( eventType, typeof(EventType) - .GetField(eventType.ToString()) + .GetField(eventType.ToString())! .GetCustomAttributes(false) .OfType() .First() @@ -201,7 +199,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken) + public async ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken) { using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken)) { @@ -234,12 +232,19 @@ namespace Tgstation.Server.Host.Components.StaticFiles static string IncludeLine(string filePath) => String.Format(CultureInfo.InvariantCulture, "#include \"{0}\"", filePath); - return new ServerSideModifications(headFileExistsTask.Result ? IncludeLine(CodeModificationsHeadFile) : null, tailFileExistsTask.Result ? IncludeLine(CodeModificationsTailFile) : null, false); + return new ServerSideModifications( + headFileExistsTask.Result + ? IncludeLine(CodeModificationsHeadFile) + : null, + tailFileExistsTask.Result + ? IncludeLine(CodeModificationsTailFile) + : null, + false); } } /// - public async ValueTask> ListDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask?> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); @@ -286,12 +291,12 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask Read(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask Read(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); - ConfigurationFileResponse result = null; + ConfigurationFileResponse? result = null; void ReadImpl() { @@ -321,7 +326,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles }, async cancellationToken => { - FileStream result = null; + FileStream? result = null; void GetFileStream() { result = ioManager.GetFileStream(path, false); @@ -332,7 +337,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles else await systemIdentity.RunImpersonated(GetFileStream, cancellationToken); - return result; + return result!; }, path, false)); @@ -453,12 +458,12 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask Write(string configurationRelativePath, ISystemIdentity systemIdentity, string previousHash, CancellationToken cancellationToken) + public async ValueTask Write(string configurationRelativePath, ISystemIdentity? systemIdentity, string? previousHash, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); - ConfigurationFileResponse result = null; + ConfigurationFileResponse? result = null; void WriteImpl() { @@ -563,7 +568,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); @@ -585,7 +590,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles await systemIdentity.RunImpersonated(DoCreate, cancellationToken); } - return result.Value; + return result!.Value; } /// @@ -659,7 +664,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); @@ -737,16 +742,16 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// /// A relative path in the instance's configuration directory. /// The full on-disk path of . - string ValidateConfigRelativePath(string configurationRelativePath) + string ValidateConfigRelativePath(string? configurationRelativePath) { var nullOrEmptyCheck = String.IsNullOrEmpty(configurationRelativePath); if (nullOrEmptyCheck) configurationRelativePath = DefaultIOManager.CurrentDirectory; - if (configurationRelativePath[0] == Path.DirectorySeparatorChar || configurationRelativePath[0] == Path.AltDirectorySeparatorChar) + if (configurationRelativePath![0] == Path.DirectorySeparatorChar || configurationRelativePath[0] == Path.AltDirectorySeparatorChar) configurationRelativePath = DefaultIOManager.CurrentDirectory + configurationRelativePath; var resolved = ioManager.ResolvePath(configurationRelativePath); var local = !nullOrEmptyCheck ? ioManager.ResolvePath() : null; - if (!nullOrEmptyCheck && resolved.Length < local.Length) // .. fuccbois + if (!nullOrEmptyCheck && resolved.Length < local!.Length) // .. fuccbois throw new InvalidOperationException("Attempted to access file outside of configuration manager!"); return resolved; } diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs index db32cc1c2b..d156df54cb 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs @@ -39,7 +39,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in an of the s for the items in the directory. and will both be . will be returned if the operation failed due to access contention. - ValueTask> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); + ValueTask?> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Reads a given . diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs b/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs index 6b7e358f0b..e28920a06e 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs @@ -13,12 +13,12 @@ /// /// The #include line which should be added to the beginning of the .dme if any. /// - public string HeadIncludeLine { get; } + public string? HeadIncludeLine { get; } /// /// The #include line which should be added to the end of the .dme if any. /// - public string TailIncludeLine { get; } + public string? TailIncludeLine { get; } /// /// Initializes a new instance of the class. @@ -26,7 +26,7 @@ /// The value of . /// The value of . /// The value of . - public ServerSideModifications(string headIncludeLine, string tailIncludeLine, bool totalDmeOverwrite) + public ServerSideModifications(string? headIncludeLine, string? tailIncludeLine, bool totalDmeOverwrite) { HeadIncludeLine = headIncludeLine; TailIncludeLine = tailIncludeLine; diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index 89231a6a49..1126bafc7d 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -69,7 +69,7 @@ namespace Tgstation.Server.Host.IO /// public async ValueTask CopyDirectory( - IEnumerable ignore, + IEnumerable? ignore, Func? postCopyCallback, string src, string dest, diff --git a/src/Tgstation.Server.Host/IO/IIOManager.cs b/src/Tgstation.Server.Host/IO/IIOManager.cs index ed4a90fb52..d88ec3ec17 100644 --- a/src/Tgstation.Server.Host/IO/IIOManager.cs +++ b/src/Tgstation.Server.Host/IO/IIOManager.cs @@ -56,7 +56,7 @@ namespace Tgstation.Server.Host.IO /// The for the operation. /// A representing the running operation. ValueTask CopyDirectory( - IEnumerable ignore, + IEnumerable? ignore, Func? postCopyCallback, string src, string dest,