mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Don't skip magnet links with included trackers if dht is disabled.
This commit is contained in:
parent
e2b91e5dc4
commit
cab900f656
@ -9,6 +9,7 @@
|
|||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Download.Clients.QBittorrent;
|
using NzbDrone.Core.Download.Clients.QBittorrent;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
using NzbDrone.Core.Exceptions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
||||||
{
|
{
|
||||||
@ -280,17 +281,33 @@ public void Download_should_get_hash_from_magnet_url(string magnetUrl, string ex
|
|||||||
id.Should().Be(expectedHash);
|
id.Should().Be(expectedHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Download_should_refuse_magnet_if_dht_is_disabled()
|
[Test]
|
||||||
|
public void Download_should_refuse_magnet_if_no_trackers_provided_and_dht_is_disabled()
|
||||||
{
|
{
|
||||||
|
|
||||||
Mocker.GetMock<IQBittorrentProxy>()
|
Mocker.GetMock<IQBittorrentProxy>()
|
||||||
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
|
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
|
||||||
.Returns(new QBittorrentPreferences() { DhtEnabled = false });
|
.Returns(new QBittorrentPreferences() { DhtEnabled = false });
|
||||||
|
|
||||||
var remoteEpisode = CreateRemoteEpisode();
|
var remoteEpisode = CreateRemoteEpisode();
|
||||||
remoteEpisode.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp";
|
remoteEpisode.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR";
|
||||||
|
|
||||||
Assert.Throws<NotSupportedException>(() => Subject.Download(remoteEpisode));
|
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteEpisode));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Download_should_accept_magnet_if_trackers_provided_and_dht_is_disabled()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IQBittorrentProxy>()
|
||||||
|
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
|
||||||
|
.Returns(new QBittorrentPreferences() { DhtEnabled = false });
|
||||||
|
|
||||||
|
var remoteEpisode = CreateRemoteEpisode();
|
||||||
|
remoteEpisode.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp://abc";
|
||||||
|
|
||||||
|
Assert.DoesNotThrow(() => Subject.Download(remoteEpisode));
|
||||||
|
|
||||||
|
Mocker.GetMock<IQBittorrentProxy>()
|
||||||
|
.Verify(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -35,9 +35,9 @@ public QBittorrent(IQBittorrentProxySelector proxySelector,
|
|||||||
|
|
||||||
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
|
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
|
||||||
{
|
{
|
||||||
if (!Proxy.GetConfig(Settings).DhtEnabled)
|
if (!Proxy.GetConfig(Settings).DhtEnabled && !magnetLink.Contains("&tr="))
|
||||||
{
|
{
|
||||||
throw new NotSupportedException("Magnet Links not supported if DHT is disabled");
|
throw new NotSupportedException("Magnet Links without trackers not supported if DHT is disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
Proxy.AddTorrentFromUrl(magnetLink, Settings);
|
Proxy.AddTorrentFromUrl(magnetLink, Settings);
|
||||||
|
Loading…
Reference in New Issue
Block a user