Fixed: Validation of new qbittorrent max-ratio action config

This commit is contained in:
Taloth Saldono 2021-01-26 10:58:27 +01:00
parent 1cbcad6960
commit d1c3ae1749
3 changed files with 12 additions and 4 deletions

View file

@ -102,13 +102,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Subject.Definition.Settings.As<QBittorrentSettings>().RecentTvPriority = (int)QBittorrentPriority.First; Subject.Definition.Settings.As<QBittorrentSettings>().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<IQBittorrentProxy>() Mocker.GetMock<IQBittorrentProxy>()
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>())) .Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
.Returns(new QBittorrentPreferences .Returns(new QBittorrentPreferences
{ {
RemoveOnMaxRatio = removeOnMaxRatio, MaxRatioAction = maxRatioAction,
MaxRatio = maxRatio, MaxRatio = maxRatio,
MaxRatioEnabled = maxRatio >= 0, MaxRatioEnabled = maxRatio >= 0,
MaxSeedingTime = maxSeedingTime, MaxSeedingTime = maxSeedingTime,

View file

@ -318,7 +318,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
// Complain if qBittorrent is configured to remove torrents on max ratio // Complain if qBittorrent is configured to remove torrents on max ratio
var config = Proxy.GetConfig(Settings); 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") return new NzbDroneValidationFailure(String.Empty, "qBittorrent is configured to remove torrents when they reach their Share Ratio Limit")
{ {

View file

@ -2,6 +2,14 @@ using Newtonsoft.Json;
namespace NzbDrone.Core.Download.Clients.QBittorrent 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 // qbittorrent settings from the list returned by /query/preferences
public class QBittorrentPreferences 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 public long MaxSeedingTime { get; set; } // Get the global share time limit in minutes
[JsonProperty(PropertyName = "max_ratio_act")] [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")] [JsonProperty(PropertyName = "queueing_enabled")]
public bool QueueingEnabled { get; set; } = true; public bool QueueingEnabled { get; set; } = true;