From dac01b49aba2c5d0296825e12656763cf42f70be Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 17 Nov 2023 23:10:22 -0500 Subject: [PATCH] Fix calling `TrustDmbPath` on multiple installers --- .../Components/Engine/ByondInstallerBase.cs | 5 ++++- .../Components/Engine/DelegatingEngineInstaller.cs | 5 ++--- .../Components/Engine/EngineInstallerBase.cs | 2 +- src/Tgstation.Server.Host/Components/Engine/EngineManager.cs | 2 +- .../Components/Engine/IEngineInstaller.cs | 3 ++- .../Components/Engine/OpenDreamInstaller.cs | 5 ++++- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs index 217c49afdf..dcbbd9b0cd 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs @@ -151,8 +151,11 @@ namespace Tgstation.Server.Host.Components.Engine } /// - public override async ValueTask TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken) + public override async ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken) { + ArgumentNullException.ThrowIfNull(version); + ArgumentNullException.ThrowIfNull(fullDmbPath); + var byondDir = PathToUserFolder; if (String.IsNullOrWhiteSpace(byondDir)) { diff --git a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs index 4a9c29cd7a..75393af5b7 100644 --- a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs @@ -5,7 +5,6 @@ using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; -using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Jobs; namespace Tgstation.Server.Host.Components.Engine @@ -46,8 +45,8 @@ namespace Tgstation.Server.Host.Components.Engine => DelegateCall(version, installer => installer.Install(version, path, cancellationToken)); /// - public ValueTask TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken) - => ValueTaskExtensions.WhenAll(delegatedInstallers.Values.Select(installer => installer.TrustDmbPath(fullDmbPath, cancellationToken))); + public ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken) + => DelegateCall(version, installer => installer.TrustDmbPath(version, fullDmbPath, cancellationToken)); /// public ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs index 2b3c986d29..e281c3f48f 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs @@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Components.Engine public abstract ValueTask DownloadVersion(EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken); /// - public abstract ValueTask TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken); + public abstract ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken); /// /// Check that a given is of type . diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs b/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs index 36365332dd..1205120411 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs @@ -176,7 +176,7 @@ namespace Tgstation.Server.Host.Components.Engine try { if (trustDmbFullPath != null) - await engineInstaller.TrustDmbPath(trustDmbFullPath, cancellationToken); + await engineInstaller.TrustDmbPath(installLock.Version, trustDmbFullPath, cancellationToken); return installLock; } diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs index 3bcd576e8d..2360202584 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs @@ -50,10 +50,11 @@ namespace Tgstation.Server.Host.Components.Engine /// /// Add a given to the trusted DMBs list in BYOND's config. /// + /// The being used. /// Full path to the .dmb that should be trusted. /// The for the operation. /// A representing the running operation. - ValueTask TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken); + ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken); /// /// Attempts to cleans the engine's cache folder for the system. diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs index 1357836c58..bbd09ed1c1 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs @@ -289,9 +289,12 @@ namespace Tgstation.Server.Host.Components.Engine } /// - public override ValueTask TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken) + public override ValueTask TrustDmbPath(EngineVersion engineVersion, string fullDmbPath, CancellationToken cancellationToken) { + ArgumentNullException.ThrowIfNull(engineVersion); ArgumentNullException.ThrowIfNull(fullDmbPath); + + Logger.LogTrace("TrustDmbPath is a no-op: {path}", fullDmbPath); return ValueTask.CompletedTask; }