Fix BYOND installer creating BYOND directory in Windows service installation

This commit is contained in:
Jordan Dominion
2023-06-25 21:00:28 -04:00
parent 7fcc1e8208
commit f7a52c98ff
2 changed files with 34 additions and 23 deletions
@@ -302,26 +302,28 @@ namespace Tgstation.Server.Host.Components.Byond
var activeVersionBytesTask = GetActiveVersion();
using (await SemaphoreSlimContext.Lock(UserFilesSemaphore, cancellationToken))
{
// Create local cfg directory in case it doesn't exist
var localCfgDirectory = ioManager.ConcatPath(
byondInstaller.PathToUserByondFolder,
CfgDirectoryName);
await ioManager.CreateDirectory(
localCfgDirectory,
cancellationToken);
// Delete trusted.txt so it doesn't grow too large
var trustedFilePath =
ioManager.ConcatPath(
var byondDir = byondInstaller.PathToUserByondFolder;
if (byondDir != null)
using (await SemaphoreSlimContext.Lock(UserFilesSemaphore, cancellationToken))
{
// Create local cfg directory in case it doesn't exist
var localCfgDirectory = ioManager.ConcatPath(
byondDir,
CfgDirectoryName);
await ioManager.CreateDirectory(
localCfgDirectory,
TrustedDmbFileName);
logger.LogTrace("Deleting trusted .dmbs file {trustedFilePath}", trustedFilePath);
await ioManager.DeleteFile(
trustedFilePath,
cancellationToken);
}
cancellationToken);
// Delete trusted.txt so it doesn't grow too large
var trustedFilePath =
ioManager.ConcatPath(
localCfgDirectory,
TrustedDmbFileName);
logger.LogTrace("Deleting trusted .dmbs file {trustedFilePath}", trustedFilePath);
await ioManager.DeleteFile(
trustedFilePath,
cancellationToken);
}
await ioManager.CreateDirectory(DefaultIOManager.CurrentDirectory, cancellationToken);
var directories = await ioManager.GetDirectories(DefaultIOManager.CurrentDirectory, cancellationToken);
@@ -616,8 +618,15 @@ namespace Tgstation.Server.Host.Components.Byond
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
async Task TrustDmbPath(string fullDmbPath, CancellationToken cancellationToken)
{
var byondDir = byondInstaller.PathToUserByondFolder;
if (String.IsNullOrWhiteSpace(byondDir))
{
logger.LogTrace("No relevant user BYOND directory to install a \"{fileName}\" in", TrustedDmbFileName);
return;
}
var trustedFilePath = ioManager.ConcatPath(
byondInstaller.PathToUserByondFolder,
byondDir,
CfgDirectoryName,
TrustedDmbFileName);
@@ -633,9 +642,7 @@ namespace Tgstation.Server.Host.Components.Byond
trustedFileText = $"{trustedFileText.Trim()}{Environment.NewLine}";
}
else
{
trustedFileText = String.Empty;
}
if (trustedFileText.Contains(fullDmbPath, StringComparison.Ordinal))
return;
@@ -94,7 +94,11 @@ namespace Tgstation.Server.Host.Components.Byond
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
PathToUserByondFolder = IOManager.ResolvePath(IOManager.ConcatPath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "BYOND"));
var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (String.IsNullOrWhiteSpace(documentsDirectory))
PathToUserByondFolder = null; // happens with the service account
else
PathToUserByondFolder = IOManager.ResolvePath(IOManager.ConcatPath(documentsDirectory, "BYOND"));
semaphore = new SemaphoreSlim(1);
installedDirectX = false;