Skip to content

Commit

Permalink
Fixed: Blocklisting torrents from indexers that do not provide torren…
Browse files Browse the repository at this point in the history
…t hash

(cherry picked from commit 3541cd7ba877fb785c7f97123745abf51162eb8e)

Closes #4308
  • Loading branch information
markus101 authored and mynameisbogdan committed Jan 9, 2024
1 parent 9cbecbf commit 9e8b9bd
Show file tree
Hide file tree
Showing 26 changed files with 178 additions and 53 deletions.
7 changes: 7 additions & 0 deletions src/NzbDrone.Core/Blocklisting/BlocklistService.cs
Expand Up @@ -15,6 +15,7 @@ namespace NzbDrone.Core.Blocklisting
public interface IBlocklistService
{
bool Blocklisted(int artistId, ReleaseInfo release);
bool BlocklistedTorrentHash(int artistId, string hash);
PagingSpec<Blocklist> Paged(PagingSpec<Blocklist> pagingSpec);
void Block(RemoteAlbum remoteAlbum, string message);
void Delete(int id);
Expand Down Expand Up @@ -62,6 +63,12 @@ public bool Blocklisted(int artistId, ReleaseInfo release)
.Any(b => SameNzb(b, release));
}

public bool BlocklistedTorrentHash(int artistId, string hash)
{
return _blocklistRepository.BlocklistedByTorrentInfoHash(artistId, hash).Any(b =>
b.TorrentInfoHash.Equals(hash, StringComparison.InvariantCultureIgnoreCase));
}

public PagingSpec<Blocklist> Paged(PagingSpec<Blocklist> pagingSpec)
{
return _blocklistRepository.GetPaged(pagingSpec);
Expand Down
4 changes: 3 additions & 1 deletion src/NzbDrone.Core/Download/Clients/Aria2/Aria2.cs
Expand Up @@ -7,6 +7,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
Expand All @@ -27,8 +28,9 @@ public class Aria2 : TorrentClientBase<Aria2Settings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;
}
Expand Down
Expand Up @@ -7,6 +7,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Organizer;
Expand All @@ -29,8 +30,9 @@ public class TorrentBlackhole : TorrentClientBase<TorrentBlackholeSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_scanWatchFolder = scanWatchFolder;

Expand Down
4 changes: 3 additions & 1 deletion src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs
Expand Up @@ -7,6 +7,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
Expand All @@ -25,8 +26,9 @@ public class Deluge : TorrentClientBase<DelugeSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;
}
Expand Down
Expand Up @@ -8,6 +8,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.MediaFiles.TorrentInfo;
Expand Down Expand Up @@ -36,8 +37,9 @@ public class TorrentDownloadStation : TorrentClientBase<DownloadStationSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_dsInfoProxy = dsInfoProxy;
_dsTaskProxySelector = dsTaskProxySelector;
Expand Down
4 changes: 3 additions & 1 deletion src/NzbDrone.Core/Download/Clients/Flood/Flood.cs
Expand Up @@ -6,6 +6,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Flood.Models;
using NzbDrone.Core.MediaFiles.TorrentInfo;
Expand All @@ -27,8 +28,9 @@ public class Flood : TorrentClientBase<FloodSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;
_downloadSeedConfigProvider = downloadSeedConfigProvider;
Expand Down
Expand Up @@ -6,6 +6,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.FreeboxDownload.Responses;
using NzbDrone.Core.MediaFiles.TorrentInfo;
Expand All @@ -24,8 +25,9 @@ public class TorrentFreeboxDownload : TorrentClientBase<FreeboxDownloadSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;
}
Expand Down
4 changes: 3 additions & 1 deletion src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs
Expand Up @@ -5,6 +5,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Hadouken.Models;
using NzbDrone.Core.MediaFiles.TorrentInfo;
Expand All @@ -24,8 +25,9 @@ public class Hadouken : TorrentClientBase<HadoukenSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;
}
Expand Down
Expand Up @@ -8,6 +8,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
Expand All @@ -34,8 +35,9 @@ private class SeedingTimeCacheEntry
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
ICacheManager cacheManager,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxySelector = proxySelector;

Expand Down
@@ -1,9 +1,10 @@
using System;
using System;
using System.Text.RegularExpressions;
using FluentValidation.Results;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.RemotePathMappings;
Expand All @@ -18,8 +19,9 @@ public class Transmission : TransmissionBase
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
}

Expand Down
Expand Up @@ -6,6 +6,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
Expand All @@ -24,8 +25,9 @@ public abstract class TransmissionBase : TorrentClientBase<TransmissionSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;
}
Expand Down
4 changes: 3 additions & 1 deletion src/NzbDrone.Core/Download/Clients/Vuze/Vuze.cs
Expand Up @@ -2,6 +2,7 @@
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Transmission;
using NzbDrone.Core.MediaFiles.TorrentInfo;
Expand All @@ -19,8 +20,9 @@ public class Vuze : TransmissionBase
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
}

Expand Down
4 changes: 3 additions & 1 deletion src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs
Expand Up @@ -8,6 +8,7 @@
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.rTorrent;
using NzbDrone.Core.Exceptions;
Expand All @@ -34,8 +35,9 @@ public class RTorrent : TorrentClientBase<RTorrentSettings>
IRemotePathMappingService remotePathMappingService,
IDownloadSeedConfigProvider downloadSeedConfigProvider,
IRTorrentDirectoryValidator rTorrentDirectoryValidator,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;
_rTorrentDirectoryValidator = rTorrentDirectoryValidator;
Expand Down
4 changes: 3 additions & 1 deletion src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs
Expand Up @@ -8,6 +8,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
Expand All @@ -28,8 +29,9 @@ public class UTorrent : TorrentClientBase<UTorrentSettings>
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IBlocklistService blocklistService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, blocklistService, logger)
{
_proxy = proxy;

Expand Down
7 changes: 6 additions & 1 deletion src/NzbDrone.Core/Download/DownloadService.cs
Expand Up @@ -102,6 +102,11 @@ private async Task DownloadReport(RemoteAlbum remoteAlbum, IDownloadClient downl
_logger.Trace("Release {0} no longer available on indexer.", remoteAlbum);
throw;
}
catch (ReleaseBlockedException)
{
_logger.Trace("Release {0} previously added to blocklist, not sending to download client again.", remoteAlbum);
throw;
}
catch (DownloadClientRejectedReleaseException)
{
_logger.Trace("Release {0} rejected by download client, possible duplicate.", remoteAlbum);
Expand All @@ -126,7 +131,7 @@ private async Task DownloadReport(RemoteAlbum remoteAlbum, IDownloadClient downl
albumGrabbedEvent.DownloadClientId = downloadClient.Definition.Id;
albumGrabbedEvent.DownloadClientName = downloadClient.Definition.Name;

if (!string.IsNullOrWhiteSpace(downloadClientId))
if (downloadClientId.IsNotNullOrWhiteSpace())
{
albumGrabbedEvent.DownloadId = downloadClientId;
}
Expand Down

0 comments on commit 9e8b9bd

Please sign in to comment.