diff --git a/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs index dd7b763f8..0a504279d 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs @@ -3,6 +3,7 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.DecisionEngine.Specifications.RssSync; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Tv; using NzbDrone.Core.Test.Framework; @@ -102,5 +103,12 @@ public void only_second_episode_not_monitored_should_return_monitored() WithSecondEpisodeUnmonitored(); _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, null).Should().BeTrue(); } + + [Test] + public void should_return_true_if_it_is_a_search() + { + _fakeSeries.Monitored = false; + _monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Should().BeTrue(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs index 301819c91..454ac01f5 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.History; +using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; @@ -122,5 +123,11 @@ public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing() _upgradeHistory.IsSatisfiedBy(_parseResultSingle, null).Should().BeFalse(); } + + [Test] + public void should_return_true_if_it_is_a_search() + { + _upgradeHistory.IsSatisfiedBy(_parseResultMulti, new SeasonSearchCriteria()).Should().BeTrue(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs b/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs index 7ad1240bc..089925c7b 100644 --- a/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/IDecisionEngineSpecification.cs @@ -5,6 +5,6 @@ namespace NzbDrone.Core.DecisionEngine { public interface IDecisionEngineSpecification : IRejectWithReason { - bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase); + bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria); } } \ No newline at end of file diff --git a/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs index 8fa00ebc2..ada1817e5 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/AcceptableSizeSpecification.cs @@ -25,7 +25,7 @@ public string RejectionReason get { return "File size too big or small"; } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { _logger.Trace("Beginning size check for: {0}", subject); diff --git a/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs index ac90c9af1..1ed27c14d 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/LanguageSpecification.cs @@ -22,7 +22,7 @@ public string RejectionReason } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { _logger.Trace("Checking if report meets language requirements. {0}", subject.ParsedEpisodeInfo.Language); if (subject.ParsedEpisodeInfo.Language != Language.English) diff --git a/NzbDrone.Core/DecisionEngine/Specifications/NotInQueueSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/NotInQueueSpecification.cs index abd4e6f88..03a2b46f6 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/NotInQueueSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/NotInQueueSpecification.cs @@ -28,7 +28,7 @@ public string RejectionReason } } - public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { var downloadClient = _downloadClientProvider.GetDownloadClient(); diff --git a/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs index 903a04dca..698c1b32b 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/NotRestrictedReleaseSpecification.cs @@ -25,7 +25,7 @@ public string RejectionReason } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { _logger.Trace("Checking if release contains any restricted terms: {0}", subject); diff --git a/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs index 93eb78bb0..40c0a3ad0 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs @@ -21,7 +21,7 @@ public string RejectionReason } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { _logger.Trace("Checking if report meets quality requirements. {0}", subject.ParsedEpisodeInfo.Quality); if (!subject.Series.QualityProfile.Value.Allowed.Contains(subject.ParsedEpisodeInfo.Quality.Quality)) diff --git a/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs index 707afc9f1..01b692adf 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/RetentionSpecification.cs @@ -25,7 +25,7 @@ public string RejectionReason } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { var age = subject.Report.Age; diff --git a/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs index 0b8e58667..2bd097e32 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/RssSync/MonitoredEpisodeSpecification.cs @@ -22,9 +22,9 @@ public string RejectionReason } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { - if (searchCriteriaBase != null) + if (searchCriteria != null) { _logger.Trace("Skipping monitored check during search"); return true; diff --git a/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs index d8f04fc7b..df4bb37b0 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/Search/DailyEpisodeMatchSpecification.cs @@ -23,14 +23,14 @@ public string RejectionReason return "Episode doesn't match"; } } - public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase) + public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) { - if (searchCriteriaBase == null) + if (searchCriteria == null) { return true; } - var dailySearchSpec = searchCriteriaBase as DailyEpisodeSearchCriteria; + var dailySearchSpec = searchCriteria as DailyEpisodeSearchCriteria; if (dailySearchSpec == null) return true; diff --git a/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs index d0a4de54f..7a42601e5 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/Search/SeasonMatchSpecification.cs @@ -21,14 +21,14 @@ public string RejectionReason } } - public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase) + public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) { - if (searchCriteriaBase == null) + if (searchCriteria == null) { return true; } - var singleEpisodeSpec = searchCriteriaBase as SeasonSearchCriteria; + var singleEpisodeSpec = searchCriteria as SeasonSearchCriteria; if (singleEpisodeSpec == null) return true; if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) diff --git a/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs index f8c64a7d5..de687692a 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/Search/SingleEpisodeSearchMatchSpecification.cs @@ -22,14 +22,14 @@ public string RejectionReason } } - public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase) + public bool IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria) { - if (searchCriteriaBase == null) + if (searchCriteria == null) { return true; } - var singleEpisodeSpec = searchCriteriaBase as SingleEpisodeSearchCriteria; + var singleEpisodeSpec = searchCriteria as SingleEpisodeSearchCriteria; if (singleEpisodeSpec == null) return true; if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) diff --git a/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs index 2f2ad815d..a67637120 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs @@ -25,7 +25,7 @@ public string RejectionReason } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) { diff --git a/NzbDrone.Core/DecisionEngine/Specifications/UpgradeHistorySpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/UpgradeHistorySpecification.cs index c17a10fc7..8a95198ff 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/UpgradeHistorySpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/UpgradeHistorySpecification.cs @@ -26,8 +26,14 @@ public string RejectionReason } } - public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteriaBase) + public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) { + if (searchCriteria != null) + { + _logger.Trace("Skipping history check during search"); + return true; + } + foreach (var episode in subject.Episodes) { var bestQualityInHistory = _historyService.GetBestQualityInHistory(episode.Id);