Fixed: Handling of priority setting when queueing is disabled in qBittorrent.
fixes #1841
This commit is contained in:
parent
de7f68570e
commit
f8b8fcfb8d
|
@ -89,6 +89,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void GivenHighPriority()
|
||||||
|
{
|
||||||
|
Subject.Definition.Settings.As<QBittorrentSettings>().OlderTvPriority = (int)QBittorrentPriority.First;
|
||||||
|
Subject.Definition.Settings.As<QBittorrentSettings>().RecentTvPriority = (int)QBittorrentPriority.First;
|
||||||
|
}
|
||||||
|
|
||||||
protected void GivenMaxRatio(float maxRatio, bool removeOnMaxRatio = true)
|
protected void GivenMaxRatio(float maxRatio, bool removeOnMaxRatio = true)
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IQBittorrentProxy>()
|
Mocker.GetMock<IQBittorrentProxy>()
|
||||||
|
@ -265,6 +271,39 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
||||||
id.Should().Be(expectedHash);
|
id.Should().Be(expectedHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Download_should_set_top_priority()
|
||||||
|
{
|
||||||
|
GivenHighPriority();
|
||||||
|
GivenSuccessfulDownload();
|
||||||
|
|
||||||
|
var remoteEpisode = CreateRemoteEpisode();
|
||||||
|
|
||||||
|
var id = Subject.Download(remoteEpisode);
|
||||||
|
|
||||||
|
Mocker.GetMock<IQBittorrentProxy>()
|
||||||
|
.Verify(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()), Times.Once());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Download_should_not_fail_if_top_priority_not_available()
|
||||||
|
{
|
||||||
|
GivenHighPriority();
|
||||||
|
GivenSuccessfulDownload();
|
||||||
|
|
||||||
|
Mocker.GetMock<IQBittorrentProxy>()
|
||||||
|
.Setup(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()))
|
||||||
|
.Throws(new HttpException(new HttpResponse(new HttpRequest("http://me.local/"), new HttpHeader(), new byte[0], System.Net.HttpStatusCode.Forbidden)));
|
||||||
|
|
||||||
|
var remoteEpisode = CreateRemoteEpisode();
|
||||||
|
|
||||||
|
var id = Subject.Download(remoteEpisode);
|
||||||
|
|
||||||
|
id.Should().NotBeNullOrEmpty();
|
||||||
|
|
||||||
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_status_with_outputdirs()
|
public void should_return_status_with_outputdirs()
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,17 +55,31 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||||
{
|
{
|
||||||
_proxy.AddTorrentFromFile(filename, fileContent, Settings);
|
_proxy.AddTorrentFromFile(filename, fileContent, Settings);
|
||||||
|
|
||||||
if (Settings.TvCategory.IsNotNullOrWhiteSpace())
|
try
|
||||||
{
|
{
|
||||||
_proxy.SetTorrentLabel(hash.ToLower(), Settings.TvCategory, Settings);
|
if (Settings.TvCategory.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
_proxy.SetTorrentLabel(hash.ToLower(), Settings.TvCategory, Settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warn(ex, "Failed to set the torrent label for {0}.", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
var isRecentEpisode = remoteEpisode.IsRecentEpisode();
|
try
|
||||||
|
|
||||||
if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First ||
|
|
||||||
!isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First)
|
|
||||||
{
|
{
|
||||||
_proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings);
|
var isRecentEpisode = remoteEpisode.IsRecentEpisode();
|
||||||
|
|
||||||
|
if (isRecentEpisode && Settings.RecentTvPriority == (int)QBittorrentPriority.First ||
|
||||||
|
!isRecentEpisode && Settings.OlderTvPriority == (int)QBittorrentPriority.First)
|
||||||
|
{
|
||||||
|
_proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warn(ex, "Failed to set the torrent priority for {0}.", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
|
@ -177,6 +191,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||||
{
|
{
|
||||||
failures.AddIfNotNull(TestConnection());
|
failures.AddIfNotNull(TestConnection());
|
||||||
if (failures.Any()) return;
|
if (failures.Any()) return;
|
||||||
|
failures.AddIfNotNull(TestPrioritySupport());
|
||||||
failures.AddIfNotNull(TestGetTorrents());
|
failures.AddIfNotNull(TestGetTorrents());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +268,41 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ValidationFailure TestPrioritySupport()
|
||||||
|
{
|
||||||
|
var recentPriorityDefault = Settings.RecentTvPriority == (int)QBittorrentPriority.Last;
|
||||||
|
var olderPriorityDefault = Settings.OlderTvPriority == (int)QBittorrentPriority.Last;
|
||||||
|
|
||||||
|
if (olderPriorityDefault && recentPriorityDefault)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var config = _proxy.GetConfig(Settings);
|
||||||
|
|
||||||
|
if (!config.QueueingEnabled)
|
||||||
|
{
|
||||||
|
if (!recentPriorityDefault)
|
||||||
|
{
|
||||||
|
return new NzbDroneValidationFailure(nameof(Settings.RecentTvPriority), "Queueing not enabled") { DetailedDescription = "Torrent Queueing is not enabled in your qBittorrent settings. Enable it in qBittorrent or select 'Last' as priority." };
|
||||||
|
}
|
||||||
|
else if (!olderPriorityDefault)
|
||||||
|
{
|
||||||
|
return new NzbDroneValidationFailure(nameof(Settings.OlderTvPriority), "Queueing not enabled") { DetailedDescription = "Torrent Queueing is not enabled in your qBittorrent settings. Enable it in qBittorrent or select 'Last' as priority." };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex);
|
||||||
|
return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private ValidationFailure TestGetTorrents()
|
private ValidationFailure TestGetTorrents()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -16,5 +16,8 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||||
|
|
||||||
[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 bool RemoveOnMaxRatio { get; set; } // Action performed when a torrent reaches the maximum share ratio. [false = pause, true = remove]
|
||||||
|
|
||||||
|
[JsonProperty(PropertyName = "queueing_enabled")]
|
||||||
|
public bool QueueingEnabled { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="checkbox toggle well">
|
<label class="checkbox toggle well">
|
||||||
<input type="checkbox" name="fields.{{order}}.value"/>
|
<input type="checkbox" name="fields.{{order}}.value" validation-name="{{name}}"/>
|
||||||
<p>
|
<p>
|
||||||
<span>Yes</span>
|
<span>Yes</span>
|
||||||
<span>No</span>
|
<span>No</span>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<label class="col-sm-3 control-label">{{label}}</label>
|
<label class="col-sm-3 control-label">{{label}}</label>
|
||||||
|
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<select name="fields.{{order}}.value" class="form-control">
|
<select name="fields.{{order}}.value" validation-name="{{name}}" class="form-control">
|
||||||
{{#each selectOptions}}
|
{{#each selectOptions}}
|
||||||
<option value="{{value}}">{{name}}</option>
|
<option value="{{value}}">{{name}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
Loading…
Reference in New Issue