From fc29a102681c5250fd74db07e62d149f9463e84b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 7 Aug 2024 17:06:28 -0700 Subject: [PATCH] fixup! Fixed: Marking queued item as failed not blocking the correct Torrent Info Hash --- src/NzbDrone.Core/Blocklisting/BlocklistService.cs | 11 +++++++++-- src/NzbDrone.Core/Download/DownloadFailedEvent.cs | 1 - src/NzbDrone.Core/Download/FailedDownloadService.cs | 13 ------------- 3 files changed, 9 insertions(+), 16 deletions(-) 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();