From 7b12eb8a6740917239cd3395561cebc1ddd109c1 Mon Sep 17 00:00:00 2001 From: Carl Johnsen Date: Thu, 5 Dec 2024 16:39:01 +0100 Subject: [PATCH] When deleting a symlink, we should check whether it is a file or a directory, as each have their own function call --- Duplicati/Library/Main/Operation/RestoreHandler.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Duplicati/Library/Main/Operation/RestoreHandler.cs b/Duplicati/Library/Main/Operation/RestoreHandler.cs index d8683b5e5..d45121e39 100644 --- a/Duplicati/Library/Main/Operation/RestoreHandler.cs +++ b/Duplicati/Library/Main/Operation/RestoreHandler.cs @@ -618,9 +618,13 @@ namespace Duplicati.Library.Main.Operation if (metadata.TryGetValue("CoreSymlinkTarget", out k)) { // Check if the target exists, and overwrite it if it does. - if (System.IO.File.Exists(targetpath) || System.IO.Directory.Exists(targetpath)) + if (SystemIO.IO_OS.FileExists(targetpath)) { - System.IO.File.Delete(targetpath); + SystemIO.IO_OS.FileDelete(targetpath); + } + else if (SystemIO.IO_OS.DirectoryExists(targetpath)) + { + SystemIO.IO_OS.DirectoryDelete(targetpath, false); } SystemIO.IO_OS.CreateSymlink(targetpath, k, isDirTarget); }