From 15de5871acfed36942509f88236578d0233964a3 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Mon, 20 Apr 2026 17:50:39 -0500 Subject: [PATCH] delete junction before recreating --- .../Playouts/Commands/SyncNextPlayoutHandler.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ErsatzTV.Application/Playouts/Commands/SyncNextPlayoutHandler.cs b/ErsatzTV.Application/Playouts/Commands/SyncNextPlayoutHandler.cs index bc8c7997b..47592e0dc 100644 --- a/ErsatzTV.Application/Playouts/Commands/SyncNextPlayoutHandler.cs +++ b/ErsatzTV.Application/Playouts/Commands/SyncNextPlayoutHandler.cs @@ -49,6 +49,20 @@ public partial class SyncNextPlayoutHandler( // re-point symlink/junction to new folder if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { + if (Directory.Exists(currentFolder)) + { + var dirInfo = new DirectoryInfo(currentFolder); + if (dirInfo.Attributes.HasFlag(FileAttributes.ReparsePoint)) + { + dirInfo.Delete(); + } + else + { + logger.LogError("Expected junction at {Folder} but found a real directory", currentFolder); + return; + } + } + var stdErrBuffer = new StringBuilder(); CommandResult command = await Cli.Wrap("cmd.exe") .WithArguments(["/c", "mklink", "/j", "current", versionFolderName])