From 91ddabe5dd4d83c55588ca1c88d2837bc40350b8 Mon Sep 17 00:00:00 2001 From: ta264 Date: Wed, 28 Aug 2019 21:14:09 +0100 Subject: [PATCH] Fixed: Catch exceptions looking up fingerprints It's not crucial so if it fails don't take out the whole import process. --- .../ParserTests/FingerprintingServiceFixture.cs | 14 ++++++++++++++ src/NzbDrone.Core/Parser/FingerprintingService.cs | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs b/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs index e004d6a1a..002f1016d 100644 --- a/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/FingerprintingServiceFixture.cs @@ -200,5 +200,19 @@ FINGERPRINT=AQAHJlMURlEURcgP6cwRD43Y4Ptw9FowncWPWkf6GB9-JYdP9OgJHw8u4Apw4SsOHMdx ExceptionVerification.ExpectedWarns(1); } + + [Test] + public void should_not_throw_if_api_times_out() + { + Mocker.GetMock().Setup(x => x.Post(It.IsAny())) + .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 }, 0.5); + localTrack.AcoustIdResults.Should().BeNull(); + + ExceptionVerification.ExpectedWarns(1); + } } } diff --git a/src/NzbDrone.Core/Parser/FingerprintingService.cs b/src/NzbDrone.Core/Parser/FingerprintingService.cs index 42b532a46..596583488 100644 --- a/src/NzbDrone.Core/Parser/FingerprintingService.cs +++ b/src/NzbDrone.Core/Parser/FingerprintingService.cs @@ -375,6 +375,11 @@ namespace NzbDrone.Core.Parser _logger.Warn(e, "AcoustId API gave invalid response"); return; } + catch (Exception e) + { + _logger.Warn(e, "AcoustId API lookup failed"); + return; + } var response = httpResponse.Resource;