From e9e36ae56a5785e5d1be704ad3167665a0ee6ae0 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 19 Sep 2023 04:07:27 +0300 Subject: [PATCH] Revert "New: Optional 'downloadClientId' for pushed releases" This reverts commit 4e01fa57fd931353c44b43ab3bb51700042cacbb. Closes #9202 --- .../Download/ProcessDownloadDecisions.cs | 120 ++++-------------- .../Download/ProcessedDecisionResult.cs | 11 -- .../Indexers/ReleasePushController.cs | 16 +-- 3 files changed, 33 insertions(+), 114 deletions(-) delete mode 100644 src/NzbDrone.Core/Download/ProcessedDecisionResult.cs diff --git a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs index 2626e88c0..592234f50 100644 --- a/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs +++ b/src/NzbDrone.Core/Download/ProcessDownloadDecisions.cs @@ -14,7 +14,6 @@ namespace NzbDrone.Core.Download public interface IProcessDownloadDecisions { Task ProcessDecisions(List decisions); - Task ProcessDecision(DownloadDecision decision, int? downloadClientId); } public class ProcessDownloadDecisions : IProcessDownloadDecisions @@ -50,6 +49,7 @@ namespace NzbDrone.Core.Download foreach (var report in prioritizedDecisions) { + var remoteMovie = report.RemoteMovie; var downloadProtocol = report.RemoteMovie.Release.DownloadProtocol; // Skip if already grabbed @@ -71,48 +71,37 @@ namespace NzbDrone.Core.Download continue; } - var result = await ProcessDecisionInternal(report); - - switch (result) + try { - case ProcessedDecisionResult.Grabbed: - { - grabbed.Add(report); - break; - } - - case ProcessedDecisionResult.Pending: - { - PreparePending(pendingAddQueue, grabbed, pending, report, PendingReleaseReason.Delay); - break; - } - - case ProcessedDecisionResult.Rejected: - { - rejected.Add(report); - break; - } + _logger.Trace("Grabbing from Indexer {0} at priority {1}.", remoteMovie.Release.Indexer, remoteMovie.Release.IndexerPriority); + await _downloadService.DownloadReport(remoteMovie, null); + grabbed.Add(report); + } + catch (ReleaseUnavailableException) + { + _logger.Warn("Failed to download release from indexer, no longer available. " + remoteMovie); + rejected.Add(report); + } + catch (Exception ex) + { + if (ex is DownloadClientUnavailableException || ex is DownloadClientAuthenticationException) + { + _logger.Debug(ex, "Failed to send release to download client, storing until later. " + remoteMovie); + PreparePending(pendingAddQueue, grabbed, pending, report, PendingReleaseReason.DownloadClientUnavailable); - case ProcessedDecisionResult.Failed: + if (downloadProtocol == DownloadProtocol.Usenet) { - PreparePending(pendingAddQueue, grabbed, pending, report, PendingReleaseReason.DownloadClientUnavailable); - - if (downloadProtocol == DownloadProtocol.Usenet) - { - usenetFailed = true; - } - else if (downloadProtocol == DownloadProtocol.Torrent) - { - torrentFailed = true; - } - - break; + usenetFailed = true; } - - case ProcessedDecisionResult.Skipped: + else if (downloadProtocol == DownloadProtocol.Torrent) { - break; + torrentFailed = true; } + } + else + { + _logger.Warn(ex, "Couldn't add report to download queue. " + remoteMovie); + } } } @@ -124,30 +113,6 @@ namespace NzbDrone.Core.Download return new ProcessedDecisions(grabbed, pending, rejected); } - public async Task ProcessDecision(DownloadDecision decision, int? downloadClientId) - { - if (decision == null) - { - return ProcessedDecisionResult.Skipped; - } - - if (decision.TemporarilyRejected) - { - _pendingReleaseService.Add(decision, PendingReleaseReason.Delay); - - return ProcessedDecisionResult.Pending; - } - - var result = await ProcessDecisionInternal(decision, downloadClientId); - - if (result == ProcessedDecisionResult.Failed) - { - _pendingReleaseService.Add(decision, PendingReleaseReason.DownloadClientUnavailable); - } - - return result; - } - internal List GetQualifiedReports(IEnumerable decisions) { // Process both approved and temporarily rejected @@ -180,38 +145,5 @@ namespace NzbDrone.Core.Download queue.Add(Tuple.Create(report, reason)); pending.Add(report); } - - private async Task ProcessDecisionInternal(DownloadDecision decision, int? downloadClientId = null) - { - var remoteMovie = decision.RemoteMovie; - - try - { - _logger.Trace("Grabbing from Indexer {0} at priority {1}.", remoteMovie.Release.Indexer, remoteMovie.Release.IndexerPriority); - await _downloadService.DownloadReport(remoteMovie, downloadClientId); - - return ProcessedDecisionResult.Grabbed; - } - catch (ReleaseUnavailableException) - { - _logger.Warn("Failed to download release from indexer, no longer available. " + remoteMovie); - return ProcessedDecisionResult.Rejected; - } - catch (Exception ex) - { - if (ex is DownloadClientUnavailableException || ex is DownloadClientAuthenticationException) - { - _logger.Debug(ex, - "Failed to send release to download client, storing until later. " + remoteMovie); - - return ProcessedDecisionResult.Failed; - } - else - { - _logger.Warn(ex, "Couldn't add report to download queue. " + remoteMovie); - return ProcessedDecisionResult.Skipped; - } - } - } } } diff --git a/src/NzbDrone.Core/Download/ProcessedDecisionResult.cs b/src/NzbDrone.Core/Download/ProcessedDecisionResult.cs deleted file mode 100644 index d1f27ed49..000000000 --- a/src/NzbDrone.Core/Download/ProcessedDecisionResult.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace NzbDrone.Core.Download -{ - public enum ProcessedDecisionResult - { - Grabbed, - Pending, - Rejected, - Failed, - Skipped - } -} diff --git a/src/Radarr.Api.V3/Indexers/ReleasePushController.cs b/src/Radarr.Api.V3/Indexers/ReleasePushController.cs index 2c15feaab..fbe4949b2 100644 --- a/src/Radarr.Api.V3/Indexers/ReleasePushController.cs +++ b/src/Radarr.Api.V3/Indexers/ReleasePushController.cs @@ -44,7 +44,6 @@ namespace Radarr.Api.V3.Indexers } [HttpPost] - [Consumes("application/json")] public ActionResult> Create(ReleaseResource release) { _logger.Info("Release pushed: {0} - {1}", release.Title, release.DownloadUrl); @@ -57,23 +56,22 @@ namespace Radarr.Api.V3.Indexers ResolveIndexer(info); - DownloadDecision decision; + List decisions; lock (PushLock) { - var decisions = _downloadDecisionMaker.GetRssDecision(new List { info }); - - decision = decisions.FirstOrDefault(); - - _downloadDecisionProcessor.ProcessDecision(decision, release.DownloadClientId).GetAwaiter().GetResult(); + decisions = _downloadDecisionMaker.GetRssDecision(new List { info }); + _downloadDecisionProcessor.ProcessDecisions(decisions).GetAwaiter().GetResult(); } - if (decision?.RemoteMovie.ParsedMovieInfo == null) + var firstDecision = decisions.FirstOrDefault(); + + if (firstDecision?.RemoteMovie.ParsedMovieInfo == null) { throw new ValidationException(new List { new ValidationFailure("Title", "Unable to parse", release.Title) }); } - return MapDecisions(new[] { decision }); + return MapDecisions(new[] { firstDecision }); } private void ResolveIndexer(ReleaseInfo release)