From 94383daac5ca90f6f4d7c9c42312d311d4f7d786 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 10 Aug 2023 00:34:11 +0300 Subject: [PATCH] Align DownloadService with upstream --- src/NzbDrone.Core/Download/DownloadService.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Download/DownloadService.cs b/src/NzbDrone.Core/Download/DownloadService.cs index e96625cdb..439d63d82 100644 --- a/src/NzbDrone.Core/Download/DownloadService.cs +++ b/src/NzbDrone.Core/Download/DownloadService.cs @@ -50,14 +50,22 @@ namespace NzbDrone.Core.Download } public void DownloadReport(RemoteAlbum remoteAlbum) + { + var filterBlockedClients = remoteAlbum.Release.PendingReleaseReason == PendingReleaseReason.DownloadClientUnavailable; + + var tags = remoteAlbum.Artist?.Tags; + + var downloadClient = _downloadClientProvider.GetDownloadClient(remoteAlbum.Release.DownloadProtocol, remoteAlbum.Release.IndexerId, filterBlockedClients, tags); + + DownloadReport(remoteAlbum, downloadClient); + } + + private void DownloadReport(RemoteAlbum remoteAlbum, IDownloadClient downloadClient) { Ensure.That(remoteAlbum.Artist, () => remoteAlbum.Artist).IsNotNull(); Ensure.That(remoteAlbum.Albums, () => remoteAlbum.Albums).HasItems(); var downloadTitle = remoteAlbum.Release.Title; - var filterBlockedClients = remoteAlbum.Release.PendingReleaseReason == PendingReleaseReason.DownloadClientUnavailable; - var tags = remoteAlbum.Artist?.Tags; - var downloadClient = _downloadClientProvider.GetDownloadClient(remoteAlbum.Release.DownloadProtocol, remoteAlbum.Release.IndexerId, filterBlockedClients, tags); if (downloadClient == null) { @@ -100,8 +108,7 @@ namespace NzbDrone.Core.Download } catch (ReleaseDownloadException ex) { - var http429 = ex.InnerException as TooManyRequestsException; - if (http429 != null) + if (ex.InnerException is TooManyRequestsException http429) { _indexerStatusService.RecordFailure(remoteAlbum.Release.IndexerId, http429.RetryAfter); }