Fixed: Incorrectly grabbing revision downgrades

Closes #4431
pull/4435/head
Mark McDowall 4 years ago
parent d7e9ccde8e
commit 5114c75cbb

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.MediaFiles;
@ -138,5 +139,19 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p);
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
}
[Test]
public void should_not_be_upgradable_if_revision_downgrade_and_preferred_word_upgrade_if_propers_are_preferred()
{
Mocker.GetMock<IEpisodeFilePreferredWordCalculator>()
.Setup(s => s.Calculate(It.IsAny<Series>(), It.IsAny<EpisodeFile>()))
.Returns(5);
_parseResultSingle.PreferredWordScore = 10;
_firstFile.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(2));
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p);
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
}
}
}

@ -39,6 +39,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
{
var qualityComparer = new QualityModelComparer(qualityProfile);
var qualityCompare = qualityComparer.Compare(newQuality?.Quality, currentQuality.Quality);
var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;
if (qualityCompare > 0)
{
@ -52,15 +53,25 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
return false;
}
var qualityRevisionComapre = newQuality?.Revision.CompareTo(currentQuality.Revision);
// Accept unless the user doesn't want to prefer propers, optionally they can
// use preferred words to prefer propers/repacks over non-propers/repacks.
if (_configService.DownloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
newQuality?.Revision.CompareTo(currentQuality.Revision) > 0)
if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
qualityRevisionComapre > 0)
{
_logger.Debug("New item has a better quality revision");
return true;
}
// Reject unless the user does not prefer propers/repacks and it's a revision downgrade.
if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
qualityRevisionComapre < 0)
{
_logger.Debug("Existing item has a better quality revision, skipping");
return false;
}
var languageCompare = new LanguageComparer(languageProfile).Compare(newLanguage, currentLanguage);
if (languageCompare > 0)
@ -77,7 +88,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (!IsPreferredWordUpgradable(currentScore, newScore))
{
_logger.Debug("Existing item has a better preferred word score, skipping");
_logger.Debug("Existing item has an equal or better preferred word score, skipping");
return false;
}

Loading…
Cancel
Save