mirror of https://github.com/lidarr/Lidarr
Fixed: Releases no longer available on the indexer should be removed from the pending queue
This commit is contained in:
parent
acd05ce6cd
commit
fa051257e3
|
@ -8,6 +8,7 @@ using NzbDrone.Core.DecisionEngine;
|
|||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
|
@ -262,5 +263,26 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
|||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.Is<RemoteAlbum>(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet)), Times.Once());
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.Is<RemoteAlbum>(r => r.Release.DownloadProtocol == DownloadProtocol.Torrent)), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_to_rejected_if_release_unavailable_on_indexer()
|
||||
{
|
||||
var albums = new List<Album> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
|
||||
Mocker.GetMock<IDownloadService>()
|
||||
.Setup(s => s.DownloadReport(It.IsAny<RemoteAlbum>()))
|
||||
.Throws(new ReleaseUnavailableException(remoteAlbum.Release, "That 404 Error is not just a Quirk"));
|
||||
|
||||
var result = Subject.ProcessDecisions(decisions);
|
||||
|
||||
result.Grabbed.Should().BeEmpty();
|
||||
result.Rejected.Should().NotBeEmpty();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,6 +179,21 @@ namespace NzbDrone.Core.Test.Download
|
|||
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_not_trigger_indexer_backoff_on_indexer_404_error()
|
||||
{
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>()))
|
||||
.Callback<RemoteAlbum>(v => {
|
||||
throw new ReleaseUnavailableException(v.Release, "Error", new WebException());
|
||||
});
|
||||
|
||||
Assert.Throws<ReleaseUnavailableException>(() => Subject.DownloadReport(_parseResult));
|
||||
|
||||
Mocker.GetMock<IIndexerStatusService>()
|
||||
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_download_if_client_isnt_configured()
|
||||
{
|
||||
|
|
|
@ -74,6 +74,11 @@ namespace NzbDrone.Core.Download
|
|||
_downloadClientStatusService.RecordSuccess(downloadClient.Definition.Id);
|
||||
_indexerStatusService.RecordSuccess(remoteAlbum.Release.IndexerId);
|
||||
}
|
||||
catch (ReleaseUnavailableException)
|
||||
{
|
||||
_logger.Trace("Release {0} no longer available on indexer.", remoteAlbum);
|
||||
throw;
|
||||
}
|
||||
catch (ReleaseDownloadException ex)
|
||||
{
|
||||
var http429 = ex.InnerException as TooManyRequestsException;
|
||||
|
|
|
@ -6,6 +6,7 @@ using NLog;
|
|||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using NzbDrone.Core.Indexers;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
|
@ -40,6 +41,7 @@ namespace NzbDrone.Core.Download
|
|||
var grabbed = new List<DownloadDecision>();
|
||||
var pending = new List<DownloadDecision>();
|
||||
var failed = new List<DownloadDecision>();
|
||||
var rejected = decisions.Where(d => d.Rejected).ToList();
|
||||
|
||||
var usenetFailed = false;
|
||||
var torrentFailed = false;
|
||||
|
@ -74,6 +76,11 @@ namespace NzbDrone.Core.Download
|
|||
_downloadService.DownloadReport(remoteAlbum);
|
||||
grabbed.Add(report);
|
||||
}
|
||||
catch (ReleaseUnavailableException)
|
||||
{
|
||||
_logger.Warn("Failed to download release from indexer, no longer available. " + remoteAlbum);
|
||||
rejected.Add(report);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is DownloadClientUnavailableException || ex is DownloadClientAuthenticationException)
|
||||
|
@ -99,7 +106,7 @@ namespace NzbDrone.Core.Download
|
|||
|
||||
pending.AddRange(ProcessFailedGrabs(grabbed, failed));
|
||||
|
||||
return new ProcessedDecisions(grabbed, pending, decisions.Where(d => d.Rejected).ToList());
|
||||
return new ProcessedDecisions(grabbed, pending, rejected);
|
||||
}
|
||||
|
||||
internal List<DownloadDecision> GetQualifiedReports(IEnumerable<DownloadDecision> decisions)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Net;
|
||||
using MonoTorrent;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -160,6 +160,12 @@ namespace NzbDrone.Core.Download
|
|||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
if (ex.Response.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
_logger.Error(ex, "Downloading torrent file for album '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, torrentUrl);
|
||||
throw new ReleaseUnavailableException(remoteAlbum.Release, "Downloading torrent failed", ex);
|
||||
}
|
||||
|
||||
if ((int)ex.Response.StatusCode == 429)
|
||||
{
|
||||
_logger.Error("API Grab Limit reached for {0}", torrentUrl);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Net;
|
||||
using System.Net;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
|
@ -46,6 +46,12 @@ namespace NzbDrone.Core.Download
|
|||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
if (ex.Response.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
_logger.Error(ex, "Downloading nzb file for album '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, url);
|
||||
throw new ReleaseUnavailableException(remoteAlbum.Release, "Downloading torrent failed", ex);
|
||||
}
|
||||
|
||||
if ((int)ex.Response.StatusCode == 429)
|
||||
{
|
||||
_logger.Error("API Grab Limit reached for {0}", url);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using NzbDrone.Common.Exceptions;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -8,24 +8,24 @@ namespace NzbDrone.Core.Exceptions
|
|||
{
|
||||
public class ArtistNotFoundException : NzbDroneException
|
||||
{
|
||||
public string SpotifyId { get; set; }
|
||||
public string MusicBrainzId { get; set; }
|
||||
|
||||
public ArtistNotFoundException(string spotifyId)
|
||||
: base(string.Format("Artist with SpotifyId {0} was not found, it may have been removed from Spotify.", spotifyId))
|
||||
public ArtistNotFoundException(string musicbrainzId)
|
||||
: base(string.Format("Artist with MusicBrainz {0} was not found, it may have been removed from MusicBrainz.", musicbrainzId))
|
||||
{
|
||||
SpotifyId = spotifyId;
|
||||
MusicBrainzId = musicbrainzId;
|
||||
}
|
||||
|
||||
public ArtistNotFoundException(string spotifyId, string message, params object[] args)
|
||||
public ArtistNotFoundException(string musicbrainzId, string message, params object[] args)
|
||||
: base(message, args)
|
||||
{
|
||||
SpotifyId = spotifyId;
|
||||
MusicBrainzId = musicbrainzId;
|
||||
}
|
||||
|
||||
public ArtistNotFoundException(string spotifyId, string message)
|
||||
public ArtistNotFoundException(string musicbrainzId, string message)
|
||||
: base(message)
|
||||
{
|
||||
SpotifyId = spotifyId;
|
||||
MusicBrainzId = musicbrainzId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Exceptions
|
||||
{
|
||||
public class ReleaseUnavailableException : ReleaseDownloadException
|
||||
{
|
||||
public ReleaseUnavailableException(ReleaseInfo release, string message, params object[] args)
|
||||
: base(release, message, args)
|
||||
{
|
||||
}
|
||||
|
||||
public ReleaseUnavailableException(ReleaseInfo release, string message)
|
||||
: base(release, message)
|
||||
{
|
||||
}
|
||||
|
||||
public ReleaseUnavailableException(ReleaseInfo release, string message, Exception innerException, params object[] args)
|
||||
: base(release, message, innerException, args)
|
||||
{
|
||||
}
|
||||
|
||||
public ReleaseUnavailableException(ReleaseInfo release, string message, Exception innerException)
|
||||
: base(release, message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Exceptions
|
||||
{
|
||||
public class SeriesNotFoundException : NzbDroneException
|
||||
{
|
||||
public int TvdbSeriesId { get; set; }
|
||||
|
||||
public SeriesNotFoundException(int tvdbSeriesId)
|
||||
: base(string.Format("Series with tvdbid {0} was not found, it may have been removed from TheTVDB.", tvdbSeriesId))
|
||||
{
|
||||
TvdbSeriesId = tvdbSeriesId;
|
||||
}
|
||||
|
||||
public SeriesNotFoundException(int tvdbSeriesId, string message, params object[] args)
|
||||
: base(message, args)
|
||||
{
|
||||
TvdbSeriesId = tvdbSeriesId;
|
||||
}
|
||||
|
||||
public SeriesNotFoundException(int tvdbSeriesId, string message)
|
||||
: base(message)
|
||||
{
|
||||
TvdbSeriesId = tvdbSeriesId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -417,7 +417,7 @@
|
|||
<Compile Include="Exceptions\BadRequestException.cs" />
|
||||
<Compile Include="Exceptions\DownstreamException.cs" />
|
||||
<Compile Include="Exceptions\NzbDroneClientException.cs" />
|
||||
<Compile Include="Exceptions\SeriesNotFoundException.cs" />
|
||||
<Compile Include="Exceptions\ReleaseUnavailableException.cs" />
|
||||
<Compile Include="Exceptions\ReleaseDownloadException.cs" />
|
||||
<Compile Include="Exceptions\StatusCodeToExceptions.cs" />
|
||||
<Compile Include="Extras\ExistingExtraFileService.cs" />
|
||||
|
|
Loading…
Reference in New Issue