Skip to content

Commit

Permalink
Fixed: Catch exceptions looking up fingerprints
Browse files Browse the repository at this point in the history
It's not crucial so if it fails don't take out the whole import process.
  • Loading branch information
ta264 committed Aug 29, 2019
1 parent 2097bff commit 91ddabe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs
Expand Up @@ -200,5 +200,19 @@ public void should_not_throw_if_api_returns_html()

ExceptionVerification.ExpectedWarns(1);
}

[Test]
public void should_not_throw_if_api_times_out()
{
Mocker.GetMock<IHttpClient>().Setup(x => x.Post<LookupResponse>(It.IsAny<HttpRequest>()))
.Throws(new System.Net.WebException("The operation has timed out."));

var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Media", "nin.mp3");
var localTrack = new LocalTrack { Path = path };
Subject.Lookup(new List<LocalTrack> { localTrack }, 0.5);
localTrack.AcoustIdResults.Should().BeNull();

ExceptionVerification.ExpectedWarns(1);
}
}
}
5 changes: 5 additions & 0 deletions src/NzbDrone.Core/Parser/FingerprintingService.cs
Expand Up @@ -375,6 +375,11 @@ public void Lookup(List<Tuple<LocalTrack, AcoustId>> files, double threshold)
_logger.Warn(e, "AcoustId API gave invalid response");
return;
}
catch (Exception e)
{
_logger.Warn(e, "AcoustId API lookup failed");
return;
}

var response = httpResponse.Resource;

Expand Down

0 comments on commit 91ddabe

Please sign in to comment.