From b8964f8bba4cd8e869b17f27f2de08108fbdcf1c Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 12 Jan 2024 02:39:27 +0200 Subject: [PATCH] Fixed: Improve torrent blocklist matching --- .../Blocklisting/BlocklistService.cs | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/NzbDrone.Core/Blocklisting/BlocklistService.cs b/src/NzbDrone.Core/Blocklisting/BlocklistService.cs index 808e3dff5..7da8f2a53 100644 --- a/src/NzbDrone.Core/Blocklisting/BlocklistService.cs +++ b/src/NzbDrone.Core/Blocklisting/BlocklistService.cs @@ -36,30 +36,28 @@ namespace NzbDrone.Core.Blocklisting public bool Blocklisted(int seriesId, ReleaseInfo release) { - var blocklistedByTitle = _blocklistRepository.BlocklistedByTitle(seriesId, release.Title); - if (release.DownloadProtocol == DownloadProtocol.Torrent) { - var torrentInfo = release as TorrentInfo; - - if (torrentInfo == null) + if (release is not TorrentInfo torrentInfo) { return false; } - if (torrentInfo.InfoHash.IsNullOrWhiteSpace()) + if (torrentInfo.InfoHash.IsNotNullOrWhiteSpace()) { - return blocklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Torrent) - .Any(b => SameTorrent(b, torrentInfo)); + var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(seriesId, torrentInfo.InfoHash); + + return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo)); } - var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(seriesId, torrentInfo.InfoHash); - - return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo)); + return _blocklistRepository.BlocklistedByTitle(seriesId, release.Title) + .Where(b => b.Protocol == DownloadProtocol.Torrent) + .Any(b => SameTorrent(b, torrentInfo)); } - return blocklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Usenet) - .Any(b => SameNzb(b, release)); + return _blocklistRepository.BlocklistedByTitle(seriesId, release.Title) + .Where(b => b.Protocol == DownloadProtocol.Usenet) + .Any(b => SameNzb(b, release)); } public bool BlocklistedTorrentHash(int seriesId, string hash)