Fix calling TrustDmbPath on multiple installers

This commit is contained in:
Jordan Dominion
2023-11-18 00:04:23 -05:00
parent fab05fdafc
commit dac01b49ab
6 changed files with 14 additions and 8 deletions
@@ -151,8 +151,11 @@ namespace Tgstation.Server.Host.Components.Engine
}
/// <inheritdoc />
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))
{
@@ -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));
/// <inheritdoc />
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));
/// <inheritdoc />
public ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken)
@@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Components.Engine
public abstract ValueTask<IEngineInstallationData> DownloadVersion(EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken);
/// <inheritdoc />
public abstract ValueTask TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken);
public abstract ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken);
/// <summary>
/// Check that a given <paramref name="version"/> is of type <see cref="EngineType.Byond"/>.
@@ -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;
}
@@ -50,10 +50,11 @@ namespace Tgstation.Server.Host.Components.Engine
/// <summary>
/// Add a given <paramref name="fullDmbPath"/> to the trusted DMBs list in BYOND's config.
/// </summary>
/// <param name="version">The <see cref="EngineVersion"/> being used.</param>
/// <param name="fullDmbPath">Full path to the .dmb that should be trusted.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="ValueTask"/> representing the running operation.</returns>
ValueTask TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken);
ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken);
/// <summary>
/// Attempts to cleans the engine's cache folder for the system.
@@ -289,9 +289,12 @@ namespace Tgstation.Server.Host.Components.Engine
}
/// <inheritdoc />
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;
}