From 8bea8a10daddf0e6f51795574afda43524336eaf Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 11 Dec 2022 18:01:51 -0800 Subject: [PATCH] Fixed: Skip anime version upgrade check if Proper/Repacks are not preferred Closes #4468 --- .../AnimeVersionUpgradeSpecificationFixture.cs | 15 +++++++++++++++ .../AnimeVersionUpgradeSpecification.cs | 14 +++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs index cd8f7dfae..5c8be79d3 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/AnimeVersionUpgradeSpecificationFixture.cs @@ -2,6 +2,7 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; @@ -21,6 +22,10 @@ public class AnimeVersionUpgradeSpecificationFixture : CoreTest() + .Setup(s => s.DownloadPropersAndRepacks) + .Returns(ProperDownloadTypes.PreferAndUpgrade); + Mocker.Resolve(); _subject = Mocker.Resolve(); @@ -104,5 +109,15 @@ public void should_be_false_when_release_group_does_not_match() { _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); } + + [Test] + public void should_return_true_when_repacks_are_not_preferred() + { + Mocker.GetMock() + .Setup(s => s.DownloadPropersAndRepacks) + .Returns(ProperDownloadTypes.DoNotPrefer); + + _subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs index 01b4e64a2..d08f8de20 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/AnimeVersionUpgradeSpecification.cs @@ -1,8 +1,10 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; namespace NzbDrone.Core.DecisionEngine.Specifications @@ -10,11 +12,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public class AnimeVersionUpgradeSpecification : IDecisionEngineSpecification { private readonly UpgradableSpecification _upgradableSpecification; + private readonly IConfigService _configService; private readonly Logger _logger; - public AnimeVersionUpgradeSpecification(UpgradableSpecification upgradableSpecification, Logger logger) + public AnimeVersionUpgradeSpecification(UpgradableSpecification upgradableSpecification, IConfigService configService, Logger logger) { _upgradableSpecification = upgradableSpecification; + _configService = configService; _logger = logger; } @@ -30,6 +34,14 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase return Decision.Accept(); } + var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks; + + if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer) + { + _logger.Debug("Version upgrades are not preferred, skipping check"); + return Decision.Accept(); + } + foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) { if (file == null)