Fixed: Improve torrent blocklist matching

This commit is contained in:
Bogdan 2024-01-12 02:39:27 +02:00 committed by GitHub
parent 53f6f64448
commit b8964f8bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 13 deletions

View File

@ -36,29 +36,27 @@ namespace NzbDrone.Core.Blocklisting
public bool Blocklisted(int seriesId, ReleaseInfo release) public bool Blocklisted(int seriesId, ReleaseInfo release)
{ {
var blocklistedByTitle = _blocklistRepository.BlocklistedByTitle(seriesId, 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)
.Any(b => SameTorrent(b, torrentInfo));
}
var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(seriesId, torrentInfo.InfoHash); var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(seriesId, torrentInfo.InfoHash);
return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo)); return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo));
} }
return blocklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Usenet) return _blocklistRepository.BlocklistedByTitle(seriesId, release.Title)
.Where(b => b.Protocol == DownloadProtocol.Torrent)
.Any(b => SameTorrent(b, torrentInfo));
}
return _blocklistRepository.BlocklistedByTitle(seriesId, release.Title)
.Where(b => b.Protocol == DownloadProtocol.Usenet)
.Any(b => SameNzb(b, release)); .Any(b => SameNzb(b, release));
} }