diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs index 799d91205b..0c617ce771 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs @@ -79,22 +79,24 @@ namespace Tgstation.Server.Host.Components.Watchdog { } /// - protected override async Task InitialLink(SwappableDmbProvider swappableDmbProvider, CancellationToken cancellationToken) + protected override async Task InitialLink(CancellationToken cancellationToken) { // The logic to check for an active live directory is in SwappableDmbProvider, so we just do it again here for safety Logger.LogTrace("Hard linking compile job..."); - // Symlinks are counted as a file sometimes?? - var dirDeleteTask = GameIOManager.DeleteDirectory(swappableDmbProvider.Directory, cancellationToken); - await GameIOManager.DeleteFile(swappableDmbProvider.Directory, cancellationToken).ConfigureAwait(false); - await dirDeleteTask.ConfigureAwait(false); + // Symlinks are counted as a file on linux?? + if (await GameIOManager.DirectoryExists(ActiveSwappable.Directory, cancellationToken).ConfigureAwait(false)) + await GameIOManager.DeleteDirectory(ActiveSwappable.Directory, cancellationToken).ConfigureAwait(false); + else + await GameIOManager.DeleteFile(ActiveSwappable.Directory, cancellationToken).ConfigureAwait(false); // Instead of symlinking to begin with we actually rename the directory await GameIOManager.MoveDirectory( - swappableDmbProvider.CompileJob.DirectoryName.ToString(), - swappableDmbProvider.Directory, + ActiveSwappable.CompileJob.DirectoryName.ToString(), + ActiveSwappable.Directory, cancellationToken) .ConfigureAwait(false); + directoryHardLinked = true; } @@ -121,6 +123,12 @@ namespace Tgstation.Server.Host.Components.Watchdog } } + if (reattachInfo != null) + { + Logger.LogTrace("Skipping symlink due to reattach"); + return; + } + Logger.LogTrace("Symlinking compile job..."); await ActiveSwappable.MakeActive(cancellationToken).ConfigureAwait(false); Server.Resume(); diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs index 1870d76ad9..a99b0d0a53 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -224,7 +224,7 @@ namespace Tgstation.Server.Host.Components.Watchdog try { - await InitialLink(ActiveSwappable, cancellationToken).ConfigureAwait(false); + await InitialLink(cancellationToken).ConfigureAwait(false); } catch { @@ -237,15 +237,14 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - /// Create the initial link to the live game directory. + /// Create the initial link to the live game directory using . /// - /// The in use. /// The for the operation. /// A representing the running operation. - protected virtual Task InitialLink(SwappableDmbProvider swappableDmbProvider, CancellationToken cancellationToken) + protected virtual Task InitialLink(CancellationToken cancellationToken) { Logger.LogTrace("Symlinking compile job..."); - return swappableDmbProvider.MakeActive(cancellationToken); + return ActiveSwappable.MakeActive(cancellationToken); } } }