When deleting a symlink, we should check whether it is a file or a directory, as each have their own function call

This commit is contained in:
Carl Johnsen
2024-12-05 16:39:01 +01:00
parent 345701576c
commit 7b12eb8a67
@@ -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);
}