Rename *SymlinkFactory to *FilesystemLinkFactory to better reflect new behavior

This commit is contained in:
Jordan Dominion
2023-10-21 18:42:19 -04:00
parent 8129773d69
commit fd6de0fee2
18 changed files with 74 additions and 74 deletions
@@ -40,19 +40,19 @@ namespace Tgstation.Server.Host.Components.Deployment
/// </summary>
/// <param name="baseProvider">The <see cref="IDmbProvider"/> for the <see cref="SwappableDmbProvider"/>.</param>
/// <param name="ioManager">The <see cref="IIOManager"/> for the <see cref="SwappableDmbProvider"/>.</param>
/// <param name="symlinkFactory">The <see cref="ISymlinkFactory"/> for the <see cref="SwappableDmbProvider"/>.</param>
/// <param name="linkFactory">The <see cref="IFilesystemLinkFactory"/> for the <see cref="SwappableDmbProvider"/>.</param>
/// <param name="logger">The value of <see cref="logger"/>.</param>
/// <param name="generalConfiguration">The <see cref="GeneralConfiguration"/> for the <see cref="HardLinkDmbProvider"/>.</param>
public HardLinkDmbProvider(
IDmbProvider baseProvider,
IIOManager ioManager,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory linkFactory,
ILogger logger,
GeneralConfiguration generalConfiguration)
: base(
baseProvider,
ioManager,
symlinkFactory)
linkFactory)
{
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
cancellationTokenSource = new CancellationTokenSource();
@@ -214,7 +214,7 @@ namespace Tgstation.Server.Host.Components.Deployment
using var lockContext = semaphore != null
? await SemaphoreSlimContext.Lock(semaphore, cancellationToken)
: null;
await SymlinkFactory.CreateHardLink(sourceFile, destFile, cancellationToken);
await LinkFactory.CreateHardLink(sourceFile, destFile, cancellationToken);
}
yield return LinkThisFile();
@@ -42,9 +42,9 @@ namespace Tgstation.Server.Host.Components.Deployment
protected IIOManager IOManager { get; }
/// <summary>
/// The <see cref="ISymlinkFactory"/> to use.
/// The <see cref="IFilesystemLinkFactory"/> to use.
/// </summary>
protected ISymlinkFactory SymlinkFactory { get; }
protected IFilesystemLinkFactory LinkFactory { get; }
/// <summary>
/// Backing field for <see cref="Swapped"/>.
@@ -56,12 +56,12 @@ namespace Tgstation.Server.Host.Components.Deployment
/// </summary>
/// <param name="baseProvider">The value of <see cref="BaseProvider"/>.</param>
/// <param name="ioManager">The value of <see cref="IOManager"/>.</param>
/// <param name="symlinkFactory">The value of <see cref="SymlinkFactory"/>.</param>
public SwappableDmbProvider(IDmbProvider baseProvider, IIOManager ioManager, ISymlinkFactory symlinkFactory)
/// <param name="symlinkFactory">The value of <see cref="LinkFactory"/>.</param>
public SwappableDmbProvider(IDmbProvider baseProvider, IIOManager ioManager, IFilesystemLinkFactory symlinkFactory)
{
BaseProvider = baseProvider ?? throw new ArgumentNullException(nameof(baseProvider));
IOManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
SymlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
LinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
}
/// <inheritdoc />
@@ -15,12 +15,12 @@ namespace Tgstation.Server.Host.Components.Deployment
/// </summary>
/// <param name="baseProvider">The <see cref="IDmbProvider"/> for the <see cref="SwappableDmbProvider"/>.</param>
/// <param name="ioManager">The <see cref="IIOManager"/> for the <see cref="SwappableDmbProvider"/>.</param>
/// <param name="symlinkFactory">The <see cref="ISymlinkFactory"/> for the <see cref="SwappableDmbProvider"/>.</param>
/// <param name="linkFactory">The <see cref="IFilesystemLinkFactory"/> for the <see cref="SwappableDmbProvider"/>.</param>
public SymlinkDmbProvider(
IDmbProvider baseProvider,
IIOManager ioManager,
ISymlinkFactory symlinkFactory)
: base(baseProvider, ioManager, symlinkFactory)
IFilesystemLinkFactory linkFactory)
: base(baseProvider, ioManager, linkFactory)
{
}
@@ -30,12 +30,12 @@ namespace Tgstation.Server.Host.Components.Deployment
/// <inheritdoc />
protected override async Task DoSwap(CancellationToken cancellationToken)
{
if (SymlinkFactory.SymlinkedDirectoriesAreDeletedAsFiles)
if (LinkFactory.SymlinkedDirectoriesAreDeletedAsFiles)
await IOManager.DeleteFile(LiveGameDirectory, cancellationToken);
else
await IOManager.DeleteDirectory(LiveGameDirectory, cancellationToken);
await SymlinkFactory.CreateSymbolicLink(
await LinkFactory.CreateSymbolicLink(
IOManager.ResolvePath(BaseProvider.Directory),
IOManager.ResolvePath(LiveGameDirectory),
cancellationToken);
@@ -66,9 +66,9 @@ namespace Tgstation.Server.Host.Components
readonly ISynchronousIOManager synchronousIOManager;
/// <summary>
/// The <see cref="ISymlinkFactory"/> for the <see cref="InstanceFactory"/>.
/// The <see cref="IFilesystemLinkFactory"/> for the <see cref="InstanceFactory"/>.
/// </summary>
readonly ISymlinkFactory symlinkFactory;
readonly IFilesystemLinkFactory linkFactory;
/// <summary>
/// The <see cref="IByondInstaller"/> for the <see cref="InstanceFactory"/>.
@@ -173,7 +173,7 @@ namespace Tgstation.Server.Host.Components
/// <param name="topicClientFactory">The value of <see cref="topicClientFactory"/>.</param>
/// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/>.</param>
/// <param name="synchronousIOManager">The value of <see cref="synchronousIOManager"/>.</param>
/// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param>
/// <param name="linkFactory">The value of <see cref="linkFactory"/>.</param>
/// <param name="byondInstaller">The value of <see cref="byondInstaller"/>.</param>
/// <param name="chatFactory">The value of <see cref="chatFactory"/>.</param>
/// <param name="processExecutor">The value of <see cref="processExecutor"/>.</param>
@@ -199,7 +199,7 @@ namespace Tgstation.Server.Host.Components
ITopicClientFactory topicClientFactory,
ICryptographySuite cryptographySuite,
ISynchronousIOManager synchronousIOManager,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory linkFactory,
IByondInstaller byondInstaller,
IChatManagerFactory chatFactory,
IProcessExecutor processExecutor,
@@ -225,7 +225,7 @@ namespace Tgstation.Server.Host.Components
this.topicClientFactory = topicClientFactory ?? throw new ArgumentNullException(nameof(topicClientFactory));
this.cryptographySuite = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
this.synchronousIOManager = synchronousIOManager ?? throw new ArgumentNullException(nameof(synchronousIOManager));
this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
this.linkFactory = linkFactory ?? throw new ArgumentNullException(nameof(linkFactory));
this.byondInstaller = byondInstaller ?? throw new ArgumentNullException(nameof(byondInstaller));
this.chatFactory = chatFactory ?? throw new ArgumentNullException(nameof(chatFactory));
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
@@ -275,7 +275,7 @@ namespace Tgstation.Server.Host.Components
var configuration = new StaticFiles.Configuration(
configurationIoManager,
synchronousIOManager,
symlinkFactory,
linkFactory,
processExecutor,
postWriteHandler,
platformIdentifier,
@@ -94,9 +94,9 @@ namespace Tgstation.Server.Host.Components.StaticFiles
readonly ISynchronousIOManager synchronousIOManager;
/// <summary>
/// The <see cref="ISymlinkFactory"/> for <see cref="Configuration"/>.
/// The <see cref="IFilesystemLinkFactory"/> for <see cref="Configuration"/>.
/// </summary>
readonly ISymlinkFactory symlinkFactory;
readonly IFilesystemLinkFactory linkFactory;
/// <summary>
/// The <see cref="IProcessExecutor"/> for <see cref="Configuration"/>.
@@ -153,7 +153,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
/// </summary>
/// <param name="ioManager">The value of <see cref="ioManager"/>.</param>
/// <param name="synchronousIOManager">The value of <see cref="synchronousIOManager"/>.</param>
/// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param>
/// <param name="linkFactory">The value of <see cref="linkFactory"/>.</param>
/// <param name="processExecutor">The value of <see cref="processExecutor"/>.</param>
/// <param name="postWriteHandler">The value of <see cref="postWriteHandler"/>.</param>
/// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/>.</param>
@@ -164,7 +164,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
public Configuration(
IIOManager ioManager,
ISynchronousIOManager synchronousIOManager,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory linkFactory,
IProcessExecutor processExecutor,
IPostWriteHandler postWriteHandler,
IPlatformIdentifier platformIdentifier,
@@ -175,7 +175,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
{
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
this.synchronousIOManager = synchronousIOManager ?? throw new ArgumentNullException(nameof(synchronousIOManager));
this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
this.linkFactory = linkFactory ?? throw new ArgumentNullException(nameof(linkFactory));
this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
this.postWriteHandler = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler));
this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
@@ -450,7 +450,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles
var fileExists = await fileExistsTask;
if (fileExists)
await ioManager.DeleteFile(destPath, cancellationToken);
await symlinkFactory.CreateSymbolicLink(ioManager.ResolvePath(file), ioManager.ResolvePath(destPath), cancellationToken);
await linkFactory.CreateSymbolicLink(ioManager.ResolvePath(file), ioManager.ResolvePath(destPath), cancellationToken);
}));
}
@@ -35,9 +35,9 @@ namespace Tgstation.Server.Host.Components.Watchdog
protected IIOManager GameIOManager { get; }
/// <summary>
/// The <see cref="ISymlinkFactory"/> for the <see cref="AdvancedWatchdog"/>.
/// The <see cref="IFilesystemLinkFactory"/> for the <see cref="AdvancedWatchdog"/>.
/// </summary>
protected ISymlinkFactory SymlinkFactory { get; }
protected IFilesystemLinkFactory LinkFactory { get; }
/// <summary>
/// <see cref="List{T}"/> of <see cref="Task"/>s that are waiting to clean up old deployments.
@@ -68,7 +68,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <param name="eventConsumer">The <see cref="IEventConsumer"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="remoteDeploymentManagerFactory">The <see cref="IRemoteDeploymentManagerFactory"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="gameIOManager">The value of <see cref="GameIOManager"/>.</param>
/// <param name="symlinkFactory">The value of <see cref="SymlinkFactory"/>.</param>
/// <param name="linkFactory">The value of <see cref="LinkFactory"/>.</param>
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param>
@@ -85,7 +85,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
IEventConsumer eventConsumer,
IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
IIOManager gameIOManager,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory linkFactory,
ILogger<AdvancedWatchdog> logger,
DreamDaemonLaunchParameters initialLaunchParameters,
Api.Models.Instance instance,
@@ -109,7 +109,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
try
{
GameIOManager = gameIOManager ?? throw new ArgumentNullException(nameof(gameIOManager));
SymlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
LinkFactory = linkFactory ?? throw new ArgumentNullException(nameof(linkFactory));
deploymentCleanupTasks = new List<Task>();
}
@@ -42,7 +42,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <param name="eventConsumer">The <see cref="IEventConsumer"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="remoteDeploymentManagerFactory">The <see cref="IRemoteDeploymentManagerFactory"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="gameIOManager">The <see cref="IIOManager"/> pointing to the game directory for the <see cref="AdvancedWatchdog"/>..</param>
/// <param name="symlinkFactory">The <see cref="ISymlinkFactory"/> for the <see cref="AdvancedWatchdog"/>.</param>
/// <param name="linkFactory">The <see cref="IFilesystemLinkFactory"/> for the <see cref="AdvancedWatchdog"/>.</param>
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param>
@@ -60,7 +60,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
IEventConsumer eventConsumer,
IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
IIOManager gameIOManager,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory linkFactory,
ILogger<PosixWatchdog> logger,
DreamDaemonLaunchParameters initialLaunchParameters,
Api.Models.Instance instance,
@@ -78,7 +78,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
eventConsumer,
remoteDeploymentManagerFactory,
gameIOManager,
symlinkFactory,
linkFactory,
logger,
initialLaunchParameters,
instance,
@@ -93,6 +93,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
protected override SwappableDmbProvider CreateSwappableDmbProvider(IDmbProvider dmbProvider)
=> new HardLinkDmbProvider(dmbProvider, GameIOManager, SymlinkFactory, Logger, generalConfiguration);
=> new HardLinkDmbProvider(dmbProvider, GameIOManager, LinkFactory, Logger, generalConfiguration);
}
}
@@ -29,21 +29,21 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="WatchdogFactory"/>.</param>
/// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogFactory"/>.</param>
/// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogFactory"/>.</param>
/// <param name="symlinkFactory">The <see cref="ISymlinkFactory"/> for the <see cref="WindowsWatchdogFactory"/>.</param>
/// <param name="linkFactory">The <see cref="IFilesystemLinkFactory"/> for the <see cref="WindowsWatchdogFactory"/>.</param>
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> for <see cref="GeneralConfiguration"/> for the <see cref="WatchdogFactory"/>.</param>
public PosixWatchdogFactory(
IServerControl serverControl,
ILoggerFactory loggerFactory,
IJobManager jobManager,
IAsyncDelayer asyncDelayer,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory linkFactory,
IOptions<GeneralConfiguration> generalConfigurationOptions)
: base(
serverControl,
loggerFactory,
jobManager,
asyncDelayer,
symlinkFactory,
linkFactory,
generalConfigurationOptions)
{
}
@@ -72,7 +72,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
eventConsumer,
remoteDeploymentManagerFactory,
gameIOManager,
SymlinkFactory,
LinkFactory,
LoggerFactory.CreateLogger<PosixWatchdog>(),
settings,
instance,
@@ -35,7 +35,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <param name="eventConsumer">The <see cref="IEventConsumer"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="remoteDeploymentManagerFactory">The <see cref="IRemoteDeploymentManagerFactory"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="gameIOManager">The <see cref="IIOManager"/> pointing to the game directory for the <see cref="AdvancedWatchdog"/>..</param>
/// <param name="symlinkFactory">The <see cref="ISymlinkFactory"/> for the <see cref="AdvancedWatchdog"/>.</param>
/// <param name="linkFactory">The <see cref="IFilesystemLinkFactory"/> for the <see cref="AdvancedWatchdog"/>.</param>
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param>
/// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param>
@@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
IEventConsumer eventConsumer,
IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
IIOManager gameIOManager,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory linkFactory,
ILogger<WindowsWatchdog> logger,
DreamDaemonLaunchParameters initialLaunchParameters,
Api.Models.Instance instance,
@@ -69,7 +69,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
eventConsumer,
remoteDeploymentManagerFactory,
gameIOManager,
symlinkFactory,
linkFactory,
logger,
initialLaunchParameters,
instance,
@@ -85,6 +85,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
protected override SwappableDmbProvider CreateSwappableDmbProvider(IDmbProvider dmbProvider)
=> new SymlinkDmbProvider(dmbProvider, GameIOManager, SymlinkFactory);
=> new SymlinkDmbProvider(dmbProvider, GameIOManager, LinkFactory);
}
}
@@ -23,9 +23,9 @@ namespace Tgstation.Server.Host.Components.Watchdog
class WindowsWatchdogFactory : WatchdogFactory
{
/// <summary>
/// The <see cref="ISymlinkFactory"/> for the <see cref="WindowsWatchdogFactory"/>.
/// The <see cref="IFilesystemLinkFactory"/> for the <see cref="WindowsWatchdogFactory"/>.
/// </summary>
protected ISymlinkFactory SymlinkFactory { get; }
protected IFilesystemLinkFactory LinkFactory { get; }
/// <summary>
/// Initializes a new instance of the <see cref="WindowsWatchdogFactory"/> class.
@@ -34,14 +34,14 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="WatchdogFactory"/>.</param>
/// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogFactory"/>.</param>
/// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogFactory"/>.</param>
/// <param name="symlinkFactory">The value of <see cref="SymlinkFactory"/>.</param>
/// <param name="symlinkFactory">The value of <see cref="LinkFactory"/>.</param>
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> for <see cref="GeneralConfiguration"/> for the <see cref="WatchdogFactory"/>.</param>
public WindowsWatchdogFactory(
IServerControl serverControl,
ILoggerFactory loggerFactory,
IJobManager jobManager,
IAsyncDelayer asyncDelayer,
ISymlinkFactory symlinkFactory,
IFilesystemLinkFactory symlinkFactory,
IOptions<GeneralConfiguration> generalConfigurationOptions)
: base(
serverControl,
@@ -50,7 +50,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
asyncDelayer,
generalConfigurationOptions)
{
SymlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
LinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
}
/// <inheritdoc />
@@ -77,7 +77,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
eventConsumer,
remoteDeploymentManagerFactory,
gameIOManager,
SymlinkFactory,
LinkFactory,
LoggerFactory.CreateLogger<WindowsWatchdog>(),
settings,
instance,
@@ -336,7 +336,7 @@ namespace Tgstation.Server.Host.Core
{
AddWatchdog<WindowsWatchdogFactory>(services, postSetupServices);
services.AddSingleton<ISystemIdentityFactory, WindowsSystemIdentityFactory>();
services.AddSingleton<ISymlinkFactory, WindowsSymlinkFactory>();
services.AddSingleton<IFilesystemLinkFactory, WindowsFilesystemLinkFactory>();
services.AddSingleton<IByondInstaller, WindowsByondInstaller>();
services.AddSingleton<IPostWriteHandler, WindowsPostWriteHandler>();
services.AddSingleton<IProcessFeatures, WindowsProcessFeatures>();
@@ -349,7 +349,7 @@ namespace Tgstation.Server.Host.Core
{
AddWatchdog<PosixWatchdogFactory>(services, postSetupServices);
services.AddSingleton<ISystemIdentityFactory, PosixSystemIdentityFactory>();
services.AddSingleton<ISymlinkFactory, PosixSymlinkFactory>();
services.AddSingleton<IFilesystemLinkFactory, PosixFilesystemLinkFactory>();
services.AddSingleton<IByondInstaller, PosixByondInstaller>();
services.AddSingleton<IPostWriteHandler, PosixPostWriteHandler>();
@@ -6,7 +6,7 @@ namespace Tgstation.Server.Host.IO
/// <summary>
/// For creating filesystem symbolic links.
/// </summary>
interface ISymlinkFactory
interface IFilesystemLinkFactory
{
/// <summary>
/// If directory symlinks must be deleted as files would in the current environment.
@@ -8,9 +8,9 @@ using Mono.Unix;
namespace Tgstation.Server.Host.IO
{
/// <summary>
/// <see cref="ISymlinkFactory"/> for posix systems.
/// <see cref="IFilesystemLinkFactory"/> for POSIX systems.
/// </summary>
sealed class PosixSymlinkFactory : ISymlinkFactory
sealed class PosixFilesystemLinkFactory : IFilesystemLinkFactory
{
/// <inheritdoc />
public bool SymlinkedDirectoriesAreDeletedAsFiles => true;
@@ -9,9 +9,9 @@ using Tgstation.Server.Host.System;
namespace Tgstation.Server.Host.IO
{
/// <summary>
/// <see cref="ISymlinkFactory"/> for windows systems.
/// <see cref="IFilesystemLinkFactory"/> for windows systems.
/// </summary>
sealed class WindowsSymlinkFactory : ISymlinkFactory
sealed class WindowsFilesystemLinkFactory : IFilesystemLinkFactory
{
/// <inheritdoc />
public bool SymlinkedDirectoriesAreDeletedAsFiles => false;
@@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles.Tests
var configuration = new Configuration(
ioManager,
new SynchronousIOManager(),
Mock.Of<ISymlinkFactory>(),
Mock.Of<IFilesystemLinkFactory>(),
Mock.Of<IProcessExecutor>(),
Mock.Of<IPostWriteHandler>(),
Mock.Of<IPlatformIdentifier>(),
@@ -8,17 +8,17 @@ using System.Threading.Tasks;
namespace Tgstation.Server.Host.IO.Tests
{
[TestClass]
public sealed class TestSymlinkFactory
public sealed class TestFilesystemLinkFactory
{
static ISymlinkFactory symlinkFactory;
static IFilesystemLinkFactory linkFactory;
[ClassInitialize]
public static void SelectFactory(TestContext _)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
symlinkFactory = new WindowsSymlinkFactory();
linkFactory = new WindowsFilesystemLinkFactory();
else
symlinkFactory = new PosixSymlinkFactory();
linkFactory = new PosixFilesystemLinkFactory();
}
public static bool HasPermissionToMakeSymlinks()
@@ -43,10 +43,10 @@ namespace Tgstation.Server.Host.IO.Tests
f2 = f1 + ".linked";
File.WriteAllText(f1, Text);
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => symlinkFactory.CreateSymbolicLink(null, null, default));
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => symlinkFactory.CreateSymbolicLink(f1, null, default));
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => linkFactory.CreateSymbolicLink(null, null, default));
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => linkFactory.CreateSymbolicLink(f1, null, default));
await symlinkFactory.CreateSymbolicLink(f1, f2, default);
await linkFactory.CreateSymbolicLink(f1, f2, default);
Assert.IsTrue(File.Exists(f2));
var f2Contents = File.ReadAllText(f2);
@@ -76,10 +76,10 @@ namespace Tgstation.Server.Host.IO.Tests
var p1 = Path.Combine(f1, FileName);
File.WriteAllText(p1, Text);
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => symlinkFactory.CreateSymbolicLink(null, null, default));
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => symlinkFactory.CreateSymbolicLink(f1, null, default));
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => linkFactory.CreateSymbolicLink(null, null, default));
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => linkFactory.CreateSymbolicLink(f1, null, default));
await symlinkFactory.CreateSymbolicLink(f1, f2, default);
await linkFactory.CreateSymbolicLink(f1, f2, default);
var p2 = Path.Combine(f2, FileName);
Assert.IsTrue(File.Exists(p2));
@@ -104,7 +104,7 @@ namespace Tgstation.Server.Host.IO.Tests
try
{
await symlinkFactory.CreateSymbolicLink(BadPath, BadPath, default);
await linkFactory.CreateSymbolicLink(BadPath, BadPath, default);
Assert.Fail("No exception thrown!");
}
catch { }
@@ -42,9 +42,9 @@ namespace Tgstation.Server.Host.IO.Tests
[TestMethod]
public async Task TestDeleteDirectoryWithSymlinkInsideDoesntRecurse()
{
var linkFactory = (ISymlinkFactory)(new PlatformIdentifier().IsWindows
? new WindowsSymlinkFactory()
: new PosixSymlinkFactory());
var linkFactory = (IFilesystemLinkFactory)(new PlatformIdentifier().IsWindows
? new WindowsFilesystemLinkFactory()
: new PosixFilesystemLinkFactory());
var tempPath = Path.GetTempFileName();
File.Delete(tempPath);
@@ -12,9 +12,9 @@ namespace Tgstation.Server.Host.System.Tests
[TestClass]
public sealed class TestSymlinkFactory
{
readonly ISymlinkFactory factory = new PlatformIdentifier().IsWindows
? new WindowsSymlinkFactory()
: new PosixSymlinkFactory();
readonly IFilesystemLinkFactory factory = new PlatformIdentifier().IsWindows
? new WindowsFilesystemLinkFactory()
: new PosixFilesystemLinkFactory();
[TestMethod]
public async Task TestSymlinks()