mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Fixed: Skip anime version upgrade check if Proper/Repacks are not preferred
Closes #4468
This commit is contained in:
parent
e42edf1d33
commit
8bea8a10da
@ -2,6 +2,7 @@
|
|||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
@ -21,6 +22,10 @@ public class AnimeVersionUpgradeSpecificationFixture : CoreTest<AnimeVersionUpgr
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
|
Mocker.GetMock<IConfigService>()
|
||||||
|
.Setup(s => s.DownloadPropersAndRepacks)
|
||||||
|
.Returns(ProperDownloadTypes.PreferAndUpgrade);
|
||||||
|
|
||||||
Mocker.Resolve<UpgradableSpecification>();
|
Mocker.Resolve<UpgradableSpecification>();
|
||||||
_subject = Mocker.Resolve<AnimeVersionUpgradeSpecification>();
|
_subject = Mocker.Resolve<AnimeVersionUpgradeSpecification>();
|
||||||
|
|
||||||
@ -104,5 +109,15 @@ public void should_be_false_when_release_group_does_not_match()
|
|||||||
{
|
{
|
||||||
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_when_repacks_are_not_preferred()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IConfigService>()
|
||||||
|
.Setup(s => s.DownloadPropersAndRepacks)
|
||||||
|
.Returns(ProperDownloadTypes.DoNotPrefer);
|
||||||
|
|
||||||
|
_subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Core.DecisionEngine.Specifications
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
@ -10,11 +12,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
|||||||
public class AnimeVersionUpgradeSpecification : IDecisionEngineSpecification
|
public class AnimeVersionUpgradeSpecification : IDecisionEngineSpecification
|
||||||
{
|
{
|
||||||
private readonly UpgradableSpecification _upgradableSpecification;
|
private readonly UpgradableSpecification _upgradableSpecification;
|
||||||
|
private readonly IConfigService _configService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public AnimeVersionUpgradeSpecification(UpgradableSpecification upgradableSpecification, Logger logger)
|
public AnimeVersionUpgradeSpecification(UpgradableSpecification upgradableSpecification, IConfigService configService, Logger logger)
|
||||||
{
|
{
|
||||||
_upgradableSpecification = upgradableSpecification;
|
_upgradableSpecification = upgradableSpecification;
|
||||||
|
_configService = configService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +34,14 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase
|
|||||||
return Decision.Accept();
|
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))
|
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
|
||||||
{
|
{
|
||||||
if (file == null)
|
if (file == null)
|
||||||
|
Loading…
Reference in New Issue
Block a user