From 29f1e639550af8af37123f050270833b8d28a333 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 12 Jan 2024 03:19:31 +0200 Subject: [PATCH] Fixed: Improve torrent blocklist matching Closes #4432 --- .../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 f19d02b15..6734a3318 100644 --- a/src/NzbDrone.Core/Blocklisting/BlocklistService.cs +++ b/src/NzbDrone.Core/Blocklisting/BlocklistService.cs @@ -37,30 +37,28 @@ public BlocklistService(IBlocklistRepository blocklistRepository) public bool Blocklisted(int artistId, ReleaseInfo release) { - var blocklistedByTitle = _blocklistRepository.BlocklistedByTitle(artistId, 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(artistId, torrentInfo.InfoHash); + + return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo)); } - var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(artistId, torrentInfo.InfoHash); - - return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo)); + return _blocklistRepository.BlocklistedByTitle(artistId, 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(artistId, release.Title) + .Where(b => b.Protocol == DownloadProtocol.Usenet) + .Any(b => SameNzb(b, release)); } public bool BlocklistedTorrentHash(int artistId, string hash)