From 294a50e0a385ece14fa937abc0962f86ba234010 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Tue, 26 Jan 2021 10:58:27 +0100 Subject: [PATCH] Fixed: Validation of new qbittorrent max-ratio action config (cherry picked from commit d1c3ae17491726320c58561548a21d83dae7fe7d) --- .../QBittorrentTests/QBittorrentFixture.cs | 4 ++-- .../Download/Clients/QBittorrent/QBittorrent.cs | 2 +- .../Clients/QBittorrent/QBittorrentPreferences.cs | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs index 88c0f1f91..120ba2f7c 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs @@ -102,13 +102,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests Subject.Definition.Settings.As().RecentTvPriority = (int)QBittorrentPriority.First; } - protected void GivenGlobalSeedLimits(float maxRatio, int maxSeedingTime = -1, bool removeOnMaxRatio = false) + protected void GivenGlobalSeedLimits(float maxRatio, int maxSeedingTime = -1, QBittorrentMaxRatioAction maxRatioAction = QBittorrentMaxRatioAction.Pause) { Mocker.GetMock() .Setup(s => s.GetConfig(It.IsAny())) .Returns(new QBittorrentPreferences { - RemoveOnMaxRatio = removeOnMaxRatio, + MaxRatioAction = maxRatioAction, MaxRatio = maxRatio, MaxRatioEnabled = maxRatio >= 0, MaxSeedingTime = maxSeedingTime, diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 74ff49841..cf92d11ad 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -349,7 +349,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.RemoveOnMaxRatio) + if ((config.MaxRatioEnabled || config.MaxSeedingTimeEnabled) && (config.MaxRatioAction == QBittorrentMaxRatioAction.Remove || config.MaxRatioAction == QBittorrentMaxRatioAction.DeleteFiles)) { return new NzbDroneValidationFailure(string.Empty, "qBittorrent is configured to remove torrents when they reach their Share Ratio Limit") { diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentPreferences.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentPreferences.cs index 4728e9b5d..e2979bd3a 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentPreferences.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentPreferences.cs @@ -2,6 +2,14 @@ using Newtonsoft.Json; namespace NzbDrone.Core.Download.Clients.QBittorrent { + public enum QBittorrentMaxRatioAction + { + Pause = 0, + Remove = 1, + EnableSuperSeeding = 2, + DeleteFiles = 3 + } + // qbittorrent settings from the list returned by /query/preferences public class QBittorrentPreferences { @@ -21,7 +29,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent public long MaxSeedingTime { get; set; } // Get the global share time limit in minutes [JsonProperty(PropertyName = "max_ratio_act")] - public bool RemoveOnMaxRatio { get; set; } // Action performed when a torrent reaches the maximum share ratio. [false = pause, true = remove] + public QBittorrentMaxRatioAction MaxRatioAction { get; set; } // Action performed when a torrent reaches the maximum share ratio. [JsonProperty(PropertyName = "queueing_enabled")] public bool QueueingEnabled { get; set; } = true;