From 1d0de5191782e756486b223d6220f479a6fa7185 Mon Sep 17 00:00:00 2001 From: Carlos Gustavo Sarmiento Date: Thu, 28 Mar 2024 06:28:41 +0100 Subject: [PATCH] Fixed: qBittorrent not correctly handling retention during testing (cherry picked from commit 588372fd950fc85f5e9a4275fbcb423b247ed0ee) --- .../Download/Clients/QBittorrent/QBittorrent.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 23f2564df..4a0edeccd 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -386,16 +386,20 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent } } - var minimumRetention = 60 * 24 * 14; - return new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost", OutputRootFolders = new List { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }, - RemovesCompletedDownloads = (config.MaxRatioEnabled || (config.MaxSeedingTimeEnabled && config.MaxSeedingTime < minimumRetention)) && (config.MaxRatioAction == QBittorrentMaxRatioAction.Remove || config.MaxRatioAction == QBittorrentMaxRatioAction.DeleteFiles) + RemovesCompletedDownloads = RemovesCompletedDownloads(config) }; } + private bool RemovesCompletedDownloads(QBittorrentPreferences config) + { + var minimumRetention = 60 * 24 * 14; // 14 days in minutes + return (config.MaxRatioEnabled || (config.MaxSeedingTimeEnabled && config.MaxSeedingTime < minimumRetention)) && (config.MaxRatioAction == QBittorrentMaxRatioAction.Remove || config.MaxRatioAction == QBittorrentMaxRatioAction.DeleteFiles); + } + protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); @@ -445,7 +449,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent // Complain if qBittorrent is configured to remove torrents on max ratio var config = Proxy.GetConfig(Settings); - if ((config.MaxRatioEnabled || config.MaxSeedingTimeEnabled) && (config.MaxRatioAction == QBittorrentMaxRatioAction.Remove || config.MaxRatioAction == QBittorrentMaxRatioAction.DeleteFiles)) + if (RemovesCompletedDownloads(config)) { return new NzbDroneValidationFailure(string.Empty, "qBittorrent is configured to remove torrents when they reach their Share Ratio Limit") {