From f79712951b081fcb4fdfcc030f9bcaa31aadbd7a Mon Sep 17 00:00:00 2001 From: "servarr[bot]" <68984020+servarr[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:53:55 +0300 Subject: [PATCH] Fixed: Assume category path from qBittorent starting with '//' is a Windows UNC path * Fixed: Assume category path from qBittorent starting with '//' is a Windows UNC path Radarr/Radarr#10162 (cherry picked from commit 19466aa29050e1b13b1db8cc61662b10d76a82e4) * fixup! Fixed: Assume category path from qBittorent starting with '//' is a Windows UNC path --------- Co-authored-by: Mark McDowall Co-authored-by: Bogdan --- .../QBittorrentTests/QBittorrentFixture.cs | 28 +++++++++++++++++++ .../Clients/QBittorrent/QBittorrent.cs | 10 ++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs index 3f58b0205..ef7161ef5 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs @@ -559,6 +559,34 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests result.OutputRootFolders.First().Should().Be(@"C:\Downloads\Finished\QBittorrent".AsOsAgnostic()); } + [Test] + public void should_correct_category_output_path() + { + var config = new QBittorrentPreferences + { + SavePath = @"C:\Downloads\Finished\QBittorrent".AsOsAgnostic() + }; + + Mocker.GetMock() + .Setup(v => v.GetConfig(It.IsAny())) + .Returns(config); + + Mocker.GetMock() + .Setup(v => v.GetApiVersion(It.IsAny())) + .Returns(new Version(2, 0)); + + Mocker.GetMock() + .Setup(s => s.GetLabels(It.IsAny())) + .Returns(new Dictionary + { { "movies-radarr", new QBittorrentLabel { Name = "movies-radarr", SavePath = "//server/store/downloads" } } }); + + var result = Subject.GetStatus(); + + result.IsLocalhost.Should().BeTrue(); + result.OutputRootFolders.Should().NotBeNull(); + result.OutputRootFolders.First().Should().Be(@"\\server\store\downloads"); + } + [Test] public async Task Download_should_handle_http_redirect_to_magnet() { diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index c4d3841df..62fc68e54 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -377,7 +377,15 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent { if (Proxy.GetLabels(Settings).TryGetValue(Settings.MovieCategory, out var label) && label.SavePath.IsNotNullOrWhiteSpace()) { - var labelDir = new OsPath(label.SavePath); + var savePath = label.SavePath; + + if (savePath.StartsWith("//")) + { + _logger.Trace("Replacing double forward slashes in path '{0}'. If this is not meant to be a Windows UNC path fix the 'Save Path' in qBittorrent's {1} category", savePath, Settings.MovieCategory); + savePath = savePath.Replace('/', '\\'); + } + + var labelDir = new OsPath(savePath); if (labelDir.IsRooted) {