From d4d4bf8784fedbf76f938685229a700a2e552e79 Mon Sep 17 00:00:00 2001 From: PearsonFlyer Date: Sun, 23 Jan 2022 15:44:19 -0500 Subject: [PATCH] Fixed: Avoid download path check false positives for Flood Closes #4825 --- src/NzbDrone.Core/Download/Clients/Flood/Flood.cs | 10 +++++++++- src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs | 10 ++++++++++ .../Clients/Flood/Types/FloodClientSettings.cs | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core/Download/Clients/Flood/Types/FloodClientSettings.cs diff --git a/src/NzbDrone.Core/Download/Clients/Flood/Flood.cs b/src/NzbDrone.Core/Download/Clients/Flood/Flood.cs index fc5224b9b..bdcad90d5 100644 --- a/src/NzbDrone.Core/Download/Clients/Flood/Flood.cs +++ b/src/NzbDrone.Core/Download/Clients/Flood/Flood.cs @@ -5,6 +5,7 @@ using System.Linq; using FluentValidation.Results; using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.Clients.Flood.Models; @@ -233,10 +234,17 @@ namespace NzbDrone.Core.Download.Clients.Flood public override DownloadClientInfo GetStatus() { + var destDir = _proxy.GetClientSettings(Settings).DirectoryDefault; + + if (Settings.Destination.IsNotNullOrWhiteSpace()) + { + destDir = Settings.Destination; + } + return new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "::1" || Settings.Host == "localhost", - OutputRootFolders = new List { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(Settings.Destination)) } + OutputRootFolders = new List { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(destDir)) } }; } diff --git a/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs b/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs index 02c2ccd8a..35e587c33 100644 --- a/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Core.Download.Clients.Flood Dictionary GetTorrents(FloodSettings settings); List GetTorrentContentPaths(string hash, FloodSettings settings); void SetTorrentsTags(string hash, IEnumerable tags, FloodSettings settings); + FloodClientSettings GetClientSettings(FloodSettings settings); } public class FloodProxy : IFloodProxy @@ -209,5 +210,14 @@ namespace NzbDrone.Core.Download.Clients.Flood HandleRequest(tagsRequest, settings); } + + public FloodClientSettings GetClientSettings(FloodSettings settings) + { + var contentsRequest = BuildRequest(settings).Resource($"/client/settings").Build(); + + contentsRequest.Method = HttpMethod.GET; + + return Json.Deserialize(HandleRequest(contentsRequest, settings).Content); + } } } diff --git a/src/NzbDrone.Core/Download/Clients/Flood/Types/FloodClientSettings.cs b/src/NzbDrone.Core/Download/Clients/Flood/Types/FloodClientSettings.cs new file mode 100644 index 000000000..49eb36b7b --- /dev/null +++ b/src/NzbDrone.Core/Download/Clients/Flood/Types/FloodClientSettings.cs @@ -0,0 +1,7 @@ +namespace NzbDrone.Core.Download.Clients.Flood.Types +{ + public class FloodClientSettings + { + public string DirectoryDefault { get; set; } + } +}