diff --git a/src/NzbDrone.Core/Blocklisting/BlocklistService.cs b/src/NzbDrone.Core/Blocklisting/BlocklistService.cs index 8b66b4612..58018c7ba 100644 --- a/src/NzbDrone.Core/Blocklisting/BlocklistService.cs +++ b/src/NzbDrone.Core/Blocklisting/BlocklistService.cs @@ -4,6 +4,7 @@ using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore; using NzbDrone.Core.Download; +using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Indexers; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; @@ -185,7 +186,6 @@ namespace NzbDrone.Core.Blocklisting Indexer = message.Data.GetValueOrDefault("indexer"), Protocol = (DownloadProtocol)Convert.ToInt32(message.Data.GetValueOrDefault("protocol")), Message = message.Message, - TorrentInfoHash = message.TorrentInfoHash, Languages = message.Languages }; @@ -199,7 +199,14 @@ namespace NzbDrone.Core.Blocklisting blocklist.ReleaseType = releaseType; } - _blocklistRepository.Insert(blocklist); + if (message.TrackedDownload == null) + { + blocklist.TorrentInfoHash = message.Data.GetValueOrDefault("torrentInfoHash", null); + } + else + { + blocklist.TorrentInfoHash = message.TrackedDownload.Protocol == DownloadProtocol.Torrent ? message.TrackedDownload.DownloadItem.DownloadId : null; + } } public void HandleAsync(SeriesDeletedEvent message) diff --git a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs index 4a9b65383..7a42b7e18 100644 --- a/src/NzbDrone.Core/Download/DownloadFailedEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadFailedEvent.cs @@ -21,7 +21,6 @@ namespace NzbDrone.Core.Download public string DownloadClient { get; set; } public string DownloadId { get; set; } public string Message { get; set; } - public string TorrentInfoHash { get; set; } public Dictionary Data { get; set; } public TrackedDownload TrackedDownload { get; set; } public List Languages { get; set; } diff --git a/src/NzbDrone.Core/Download/FailedDownloadService.cs b/src/NzbDrone.Core/Download/FailedDownloadService.cs index a9bc84524..356df10d2 100644 --- a/src/NzbDrone.Core/Download/FailedDownloadService.cs +++ b/src/NzbDrone.Core/Download/FailedDownloadService.cs @@ -125,8 +125,6 @@ namespace NzbDrone.Core.Download { Enum.TryParse(historyItem.Data.GetValueOrDefault(EpisodeHistory.RELEASE_SOURCE, ReleaseSourceType.Unknown.ToString()), out ReleaseSourceType releaseSource); - var torrentInfoHash = GetTorrentInfoHash(historyItem, trackedDownload); - var downloadFailedEvent = new DownloadFailedEvent { SeriesId = historyItem.SeriesId, @@ -141,22 +139,11 @@ namespace NzbDrone.Core.Download Languages = historyItem.Languages, SkipRedownload = skipRedownload, ReleaseSource = releaseSource, - TorrentInfoHash = torrentInfoHash }; _eventAggregator.PublishEvent(downloadFailedEvent); } - private string GetTorrentInfoHash(EpisodeHistory historyItem, TrackedDownload trackedDownload) - { - if (trackedDownload == null) - { - return historyItem.Data.GetValueOrDefault("torrentInfoHash", null); - } - - return trackedDownload.Protocol == DownloadProtocol.Torrent ? trackedDownload.DownloadItem.DownloadId : null; - } - private List GetEpisodeIds(List historyItems) { return historyItems.Select(h => h.EpisodeId).Distinct().ToList();