From 96b51a02e2f72587b9520ff2981837fece1b8683 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 27 Oct 2024 00:22:16 +0300 Subject: [PATCH] Fixed: Status check for completed directories in Deluge (cherry picked from commit 33139d4b53c1adad769c7e2b0510e8990c66b84a) --- .../DelugeTests/DelugeFixture.cs | 24 +++++++++++++++---- .../Download/Clients/Deluge/Deluge.cs | 13 ++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs index 58a37472d..79a24330c 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs @@ -312,11 +312,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests [Test] public void should_return_status_with_outputdirs() { - var configItems = new Dictionary(); - - configItems.Add("download_location", @"C:\Downloads\Downloading\deluge".AsOsAgnostic()); - configItems.Add("move_completed_path", @"C:\Downloads\Finished\deluge".AsOsAgnostic()); - configItems.Add("move_completed", true); + var configItems = new Dictionary + { + { "download_location", @"C:\Downloads\Downloading\deluge".AsOsAgnostic() }, + { "move_completed_path", @"C:\Downloads\Finished\deluge".AsOsAgnostic() }, + { "move_completed", true } + }; Mocker.GetMock() .Setup(v => v.GetConfig(It.IsAny())) @@ -328,5 +329,18 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests result.OutputRootFolders.Should().NotBeNull(); result.OutputRootFolders.First().Should().Be(@"C:\Downloads\Finished\deluge".AsOsAgnostic()); } + + [Test] + public void should_return_status_with_outputdirs_for_directories_in_settings() + { + Subject.Definition.Settings.As().DownloadDirectory = @"D:\Downloads\Downloading\deluge".AsOsAgnostic(); + Subject.Definition.Settings.As().CompletedDirectory = @"D:\Downloads\Finished\deluge".AsOsAgnostic(); + + var result = Subject.GetStatus(); + + result.IsLocalhost.Should().BeTrue(); + result.OutputRootFolders.Should().NotBeNull(); + result.OutputRootFolders.First().Should().Be(@"D:\Downloads\Finished\deluge".AsOsAgnostic()); + } } } diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 0d35341f6..8d685ed5d 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -214,9 +214,18 @@ namespace NzbDrone.Core.Download.Clients.Deluge { var config = _proxy.GetConfig(Settings); var label = _proxy.GetLabelOptions(Settings); + OsPath destDir; - if (label != null && label.ApplyMoveCompleted && label.MoveCompleted) + if (Settings.CompletedDirectory.IsNotNullOrWhiteSpace()) + { + destDir = new OsPath(Settings.CompletedDirectory); + } + else if (Settings.DownloadDirectory.IsNotNullOrWhiteSpace()) + { + destDir = new OsPath(Settings.DownloadDirectory); + } + else if (label is { ApplyMoveCompleted: true, MoveCompleted: true }) { // if label exists and a label completed path exists and is enabled use it instead of global destDir = new OsPath(label.MoveCompletedPath); @@ -232,7 +241,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge var status = new DownloadClientInfo { - IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" + IsLocalhost = Settings.Host is "127.0.0.1" or "localhost" }; if (!destDir.IsEmpty)