diff --git a/build/Version.props b/build/Version.props index 7ebed1db38..dc72d597a5 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 4.10.5 + 4.10.6 3.0.0 9.0.1 9.0.0 diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs index a567614202..a028bc497d 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs @@ -719,7 +719,7 @@ namespace Tgstation.Server.Host.Components.Deployment repoName, cancellationToken); - var eventTask = eventConsumer.HandleEvent(EventType.DeploymentComplete, null, cancellationToken); + var eventTask = eventConsumer.HandleEvent(EventType.DeploymentComplete, Enumerable.Empty(), cancellationToken); try { @@ -841,7 +841,7 @@ namespace Tgstation.Server.Host.Components.Deployment catch (OperationCanceledException) { // DCT: Cancellation token is for job, delaying here is fine - await eventConsumer.HandleEvent(EventType.CompileCancelled, null, default).ConfigureAwait(false); + await eventConsumer.HandleEvent(EventType.CompileCancelled, Enumerable.Empty(), default).ConfigureAwait(false); throw; } finally diff --git a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs index 45cb18f0a0..9df9ce74df 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -32,6 +32,9 @@ namespace Tgstation.Server.Host.Components.Events /// public async Task HandleEvent(EventType eventType, IEnumerable parameters, CancellationToken cancellationToken) { + if (parameters == null) + throw new ArgumentNullException(nameof(parameters)); + if (watchdog == null) throw new InvalidOperationException("EventConsumer used without watchdog set!"); diff --git a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs index 6dbf73fe87..8d2cc4c03d 100644 --- a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs @@ -1,20 +1,20 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace Tgstation.Server.Host.Components.Events { /// - /// Consumes s and takes the appropriate actions + /// Consumes s and takes the appropriate actions. /// public interface IEventConsumer { /// - /// Handle a given + /// Handle a given . /// - /// The - /// The parameters for - /// The for the operation + /// The . + /// An of parameters for . + /// The for the operation. /// A representing the running operation. Task HandleEvent(EventType eventType, IEnumerable parameters, CancellationToken cancellationToken); } diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 8a10a76828..c5e13de2ae 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -375,9 +375,9 @@ namespace Tgstation.Server.Host.Components while (true) try { - await Task.Delay(TimeSpan.FromMinutes(minutes > Int32.MaxValue ? Int32.MaxValue : (int)minutes), cancellationToken).ConfigureAwait(false); + await Task.Delay(TimeSpan.FromMinutes(minutes > Int32.MaxValue ? Int32.MaxValue : minutes), cancellationToken).ConfigureAwait(false); logger.LogInformation("Beginning auto update..."); - await eventConsumer.HandleEvent(EventType.InstanceAutoUpdateStart, new List(), cancellationToken).ConfigureAwait(false); + await eventConsumer.HandleEvent(EventType.InstanceAutoUpdateStart, Enumerable.Empty(), cancellationToken).ConfigureAwait(false); try { var repositoryUpdateJob = new Job diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs index 860db0379f..9ab63c7ffc 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Tgstation.Server.Host.Components.Events; @@ -18,17 +19,17 @@ namespace Tgstation.Server.Host.Components.Interop.Topic /// /// The set of parameters. /// - public IReadOnlyCollection Parameters { get; } + public IReadOnlyCollection Parameters { get; } /// /// Initializes a new instance of the . /// /// The value of . /// The that forms the value of . - public EventNotification(EventType eventType, IEnumerable parameters = null) + public EventNotification(EventType eventType, IEnumerable parameters = null) { Type = eventType; - Parameters = parameters?.ToList(); + Parameters = parameters?.ToList() ?? throw new ArgumentNullException(nameof(parameters)); ; } } } diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index 3cf8df9d21..fe593874c6 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -440,7 +440,7 @@ namespace Tgstation.Server.Host.Components.Repository if (progressReporter == null) throw new ArgumentNullException(nameof(progressReporter)); logger.LogDebug("Fetch origin..."); - await eventConsumer.HandleEvent(EventType.RepoFetch, Array.Empty(), cancellationToken).ConfigureAwait(false); + await eventConsumer.HandleEvent(EventType.RepoFetch, Enumerable.Empty(), cancellationToken).ConfigureAwait(false); await Task.Factory.StartNew(() => { var remote = libGitRepo.Network.Remotes.First(); diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index 6c03ceae3b..6dd9e2b682 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -546,6 +546,9 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// public async Task HandleEvent(EventType eventType, IEnumerable parameters, CancellationToken cancellationToken) { + if (parameters == null) + throw new ArgumentNullException(nameof(parameters)); + await EnsureDirectories(cancellationToken).ConfigureAwait(false); if (!EventTypeScriptFileNameMap.TryGetValue(eventType, out var scriptName)) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index ae77048ee1..ade3400107 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -841,6 +841,9 @@ namespace Tgstation.Server.Host.Components.Watchdog /// async Task IEventConsumer.HandleEvent(EventType eventType, IEnumerable parameters, CancellationToken cancellationToken) { + if (parameters == null) + throw new ArgumentNullException(nameof(parameters)); + // Method explicitly implemented to prevent accidental calls when this.eventConsumer should be used. var activeServer = GetActiveController();