From 4f5c437ddd5a4049a9c85a1eff660af805363652 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 15 Jan 2015 23:10:28 -0800 Subject: [PATCH] Fixed: Don't search for newly added episodes if they aren't monitored --- .../EpisodeInfoRefreshedSearchFixture.cs | 27 ++++++++++++++++++- .../IndexerSearch/EpisodeSearchService.cs | 12 +++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/EpisodeInfoRefreshedSearchFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/EpisodeInfoRefreshedSearchFixture.cs index 6a60eae6c..fd8fd82b0 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/EpisodeInfoRefreshedSearchFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/EpisodeInfoRefreshedSearchFixture.cs @@ -24,6 +24,7 @@ public void Setup() { _series = Builder.CreateNew() .With(s => s.Added = DateTime.UtcNow.AddDays(-7)) + .With(s => s.Monitored = true) .Build(); _added = new List(); @@ -96,12 +97,36 @@ public void should_not_search_if_episodes_air_in_the_future() VerifyNoSearch(); } + [Test] + public void should_not_search_if_series_is_not_monitored() + { + GivenUpdated(); + + _series.Monitored = false; + + Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated)); + + VerifyNoSearch(); + } + + [Test] + public void should_not_search_if_episode_is_not_monitored() + { + GivenUpdated(); + + _added.Add(new Episode { AirDateUtc = DateTime.UtcNow, Monitored = false }); + + Subject.Handle(new EpisodeInfoRefreshedEvent(_series, _added, _updated)); + + VerifyNoSearch(); + } + [Test] public void should_search_for_a_newly_added_episode() { GivenUpdated(); - _added.Add(new Episode { AirDateUtc = DateTime.UtcNow }); + _added.Add(new Episode { AirDateUtc = DateTime.UtcNow, Monitored = true }); Mocker.GetMock() .Setup(s => s.ProcessDecisions(It.IsAny>())) diff --git a/src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs b/src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs index 84e65e813..3ea4909c3 100644 --- a/src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs @@ -113,6 +113,12 @@ public void Execute(MissingEpisodeSearchCommand message) public void Handle(EpisodeInfoRefreshedEvent message) { + if (!message.Series.Monitored) + { + _logger.Debug("Series is not monitored"); + return; + } + if (message.Updated.Empty() || message.Series.Added.InLastDays(1)) { _logger.Debug("Appears to be a new series, skipping search."); @@ -141,6 +147,12 @@ public void Handle(EpisodeInfoRefreshedEvent message) foreach (var episode in previouslyAired) { + if (!episode.Monitored) + { + _logger.Debug("Episode is not monitored"); + continue; + } + var decisions = _nzbSearchService.EpisodeSearch(episode); var processed = _processDownloadDecisions.ProcessDecisions(decisions);