From 87892a1d0cd189d203f7930b856287988c6647ff Mon Sep 17 00:00:00 2001 From: Touchstone64 Date: Mon, 1 Dec 2025 11:16:17 +0000 Subject: [PATCH] Fixed: Prevent paths with multiple slashes causing backups to fail Closes #8221 --- .../DiskTests/DiskTransferServiceFixture.cs | 15 +++++++++++++++ src/NzbDrone.Common/Disk/DiskTransferService.cs | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs index cd491e68a..24a961129 100644 --- a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs +++ b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs @@ -579,6 +579,21 @@ public void MoveFolder_should_rename_casesensitive_folder() Directory.Exists(destination.FullName).Should().Be(true); } + [Test] + public void TransferFile_should_find_files_with_multiple_slashes_within_their_path() + { + WithRealDiskProvider(); + + var root = GetFilledTempFolder(); + var rootDir = root.FullName; + var from = Path.Combine(rootDir, "source-file"); + var toRootDir = rootDir.Replace(Path.DirectorySeparatorChar.ToString(), new string(Path.DirectorySeparatorChar, 3)); + var to = Path.Combine(toRootDir, "destination-file"); + File.WriteAllText(from, "Source file"); + var mode = Subject.TransferFile(from, to, TransferMode.Copy); + mode.Should().Be(TransferMode.Copy); + } + [Test] public void should_throw_if_destination_is_readonly() { diff --git a/src/NzbDrone.Common/Disk/DiskTransferService.cs b/src/NzbDrone.Common/Disk/DiskTransferService.cs index f89c31b21..36bcbcc3e 100644 --- a/src/NzbDrone.Common/Disk/DiskTransferService.cs +++ b/src/NzbDrone.Common/Disk/DiskTransferService.cs @@ -28,15 +28,15 @@ public DiskTransferService(IDiskProvider diskProvider, Logger logger) private string ResolveRealParentPath(string path) { - var parentPath = path.GetParentPath(); - if (!_diskProvider.FolderExists(parentPath)) + if (!_diskProvider.FolderExists(path.GetParentPath())) { return path; } + var cleanPath = path.GetCleanPath(); + var parentPath = cleanPath.GetParentPath(); var realParentPath = parentPath.GetActualCasing(); - - var partialChildPath = path.Substring(parentPath.Length); + var partialChildPath = cleanPath.Substring(parentPath.Length); return realParentPath + partialChildPath; }