From 54bd3c0b4917a69bb599169ec8ba8aeae6a62f34 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 8 Oct 2017 00:43:07 -0400 Subject: [PATCH] Fixed up some errors and do the guid cache fix on the module instead of backend coz that would cause other issues. --- src/Lidarr.Api.V3/Indexers/ReleaseModule.cs | 16 +++++++++++----- .../TorrentRssSettingsDetectorFixture.cs | 5 +---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Lidarr.Api.V3/Indexers/ReleaseModule.cs b/src/Lidarr.Api.V3/Indexers/ReleaseModule.cs index 9922c661d..07d7a6de6 100644 --- a/src/Lidarr.Api.V3/Indexers/ReleaseModule.cs +++ b/src/Lidarr.Api.V3/Indexers/ReleaseModule.cs @@ -53,7 +53,7 @@ namespace Lidarr.Api.V3.Indexers private Response DownloadRelease(ReleaseResource release) { - var remoteAlbum = _remoteAlbumCache.Find(release.Guid); + var remoteAlbum = _remoteAlbumCache.Find(GetCacheKey(release)); if (remoteAlbum == null) { @@ -68,7 +68,7 @@ namespace Lidarr.Api.V3.Indexers } catch (ReleaseDownloadException ex) { - _logger.ErrorException(ex.Message, ex); + _logger.Error(ex, ex.Message); throw new NzbDroneClientException(HttpStatusCode.Conflict, "Getting release from indexer failed"); } @@ -96,7 +96,7 @@ namespace Lidarr.Api.V3.Indexers } catch (Exception ex) { - _logger.ErrorException("Album search failed: " + ex.Message, ex); + _logger.Error(ex, "Album search failed: " + ex.Message); } return new List(); @@ -113,8 +113,14 @@ namespace Lidarr.Api.V3.Indexers protected override ReleaseResource MapDecision(DownloadDecision decision, int initialWeight) { - _remoteAlbumCache.Set(decision.RemoteAlbum.Release.Guid, decision.RemoteAlbum, TimeSpan.FromMinutes(30)); - return base.MapDecision(decision, initialWeight); + var resource = base.MapDecision(decision, initialWeight); + _remoteAlbumCache.Set(GetCacheKey(resource), decision.RemoteAlbum, TimeSpan.FromMinutes(30)); + return resource; + } + + private string GetCacheKey(ReleaseResource resource) + { + return string.Concat(resource.IndexerId, "_", resource.Guid); } } } diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs index 74934b160..e8222f7d5 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorrentRssIndexerTests/TorrentRssSettingsDetectorFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common.Http; @@ -253,12 +253,9 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests }); } - [TestCase("BitMeTv/BitMeTv.xml")] - [TestCase("Fanzub/fanzub.xml")] [TestCase("IPTorrents/IPTorrents.xml")] [TestCase("Newznab/newznab_nzb_su.xml")] [TestCase("Nyaa/Nyaa.xml")] - [TestCase("Omgwtfnzbs/Omgwtfnzbs.xml")] [TestCase("Torznab/torznab_hdaccess_net.xml")] [TestCase("Torznab/torznab_tpb.xml")] public void should_detect_recent_feed(string rssXmlFile)