Specify Environment.SpecialFolderOption where possible

Also fix a typo
This commit is contained in:
Jordan Dominion
2023-11-29 17:32:26 -05:00
parent 2702a2fc2b
commit c40197fcb5
8 changed files with 24 additions and 18 deletions
+3 -1
View File
@@ -179,7 +179,9 @@ namespace Tgstation.Server.Host.Service
var exePath = Path.Combine(assemblyDirectory, $"{assemblyNameWithoutExtension}.exe");
var programDataDirectory = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
Environment.GetFolderPath(
Environment.SpecialFolder.CommonApplicationData,
Environment.SpecialFolderOption.DoNotVerify),
Server.Common.Constants.CanonicalPackageName);
using var processInstaller = new ServiceProcessInstaller();
@@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.Components.Engine
protected override EngineType TargetEngineType => EngineType.Byond;
/// <summary>
/// Bath to the system user's local BYOND folder.
/// Path to the system user's local BYOND folder.
/// </summary>
protected abstract string PathToUserFolder { get; }
@@ -157,12 +157,6 @@ namespace Tgstation.Server.Host.Components.Engine
ArgumentNullException.ThrowIfNull(fullDmbPath);
var byondDir = PathToUserFolder;
if (String.IsNullOrWhiteSpace(byondDir))
{
Logger.LogTrace("No relevant user BYOND directory to install a \"{fileName}\" in", TrustedDmbFileName);
return;
}
var cfgDir = IOManager.ConcatPath(
byondDir,
CfgDirectoryName);
@@ -65,7 +65,8 @@ namespace Tgstation.Server.Host.Components.Engine
PathToUserFolder = IOManager.ResolvePath(
IOManager.ConcatPath(
Environment.GetFolderPath(
Environment.SpecialFolder.UserProfile),
Environment.SpecialFolder.UserProfile,
Environment.SpecialFolderOption.DoNotVerify),
"./byond/cache"));
}
@@ -100,11 +100,12 @@ namespace Tgstation.Server.Host.Components.Engine
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (String.IsNullOrWhiteSpace(documentsDirectory))
PathToUserFolder = null; // happens with the service account
else
PathToUserFolder = IOManager.ResolvePath(IOManager.ConcatPath(documentsDirectory, "BYOND"));
var documentsDirectory = Environment.GetFolderPath(
Environment.SpecialFolder.MyDocuments,
Environment.SpecialFolderOption.DoNotVerify);
PathToUserFolder = IOManager.ResolvePath(
IOManager.ConcatPath(documentsDirectory, "BYOND"));
semaphore = new SemaphoreSlim(1);
installedDirectX = false;
@@ -62,7 +62,9 @@ namespace Tgstation.Server.Host.Configuration
return platformIdentifier.IsWindows
? ioManager.ConcatPath(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
Environment.GetFolderPath(
Environment.SpecialFolder.CommonApplicationData,
Environment.SpecialFolderOption.DoNotVerify),
assemblyInformationProvider.VersionPrefix,
"logs")
: ioManager.ConcatPath(
@@ -367,7 +367,9 @@ namespace Tgstation.Server.Host.Core
// only global repo manager should be for the OD repo
var openDreamRepositoryDirectory = ioManager.ConcatPath(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.DoNotVerify),
assemblyInformationProvider.VersionPrefix,
"OpenDreamRepository");
services.AddSingleton(
@@ -94,7 +94,9 @@ namespace Tgstation.Server.Tests
// actions is supposed to cache BYOND for us
var dir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
Environment.GetFolderPath(
Environment.SpecialFolder.UserProfile,
Environment.SpecialFolderOption.DoNotVerify),
"byond-zips-cache",
windows ? "windows" : "linux");
path = Path.Combine(
@@ -85,7 +85,9 @@ namespace Tgstation.Server.Tests.Live.Instance
{
var ioManager = new DefaultIOManager();
var odRepoDir = ioManager.ConcatPath(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.DoNotVerify),
new AssemblyInformationProvider().VersionPrefix,
"OpenDreamRepository");
var odRepoIoManager = new ResolvingIOManager(ioManager, odRepoDir);