Fixed: Improve torrent blocklist matching

Closes #3184
pull/3185/head
Bogdan 1 year ago
parent 518dbe53eb
commit 9d27c172ac

@ -37,30 +37,28 @@ namespace NzbDrone.Core.Blocklisting
public bool Blocklisted(int authorId, ReleaseInfo release) public bool Blocklisted(int authorId, ReleaseInfo release)
{ {
var blocklistedByTitle = _blocklistRepository.BlocklistedByTitle(authorId, release.Title);
if (release.DownloadProtocol == DownloadProtocol.Torrent) if (release.DownloadProtocol == DownloadProtocol.Torrent)
{ {
var torrentInfo = release as TorrentInfo; if (release is not TorrentInfo torrentInfo)
if (torrentInfo == null)
{ {
return false; return false;
} }
if (torrentInfo.InfoHash.IsNullOrWhiteSpace()) if (torrentInfo.InfoHash.IsNotNullOrWhiteSpace())
{ {
return blocklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Torrent) var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(authorId, torrentInfo.InfoHash);
.Any(b => SameTorrent(b, torrentInfo));
}
var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(authorId, torrentInfo.InfoHash); return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo));
}
return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo)); return _blocklistRepository.BlocklistedByTitle(authorId, release.Title)
.Where(b => b.Protocol == DownloadProtocol.Torrent)
.Any(b => SameTorrent(b, torrentInfo));
} }
return blocklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Usenet) return _blocklistRepository.BlocklistedByTitle(authorId, release.Title)
.Any(b => SameNzb(b, release)); .Where(b => b.Protocol == DownloadProtocol.Usenet)
.Any(b => SameNzb(b, release));
} }
public bool BlocklistedTorrentHash(int authorId, string hash) public bool BlocklistedTorrentHash(int authorId, string hash)

Loading…
Cancel
Save