Fixed: Incorrectly grabbing revision downgrades (#6194)

This commit is contained in:
Robin Dadswell 2021-04-24 18:14:27 +01:00 committed by GitHub
parent 7807e2e13a
commit ce6f52552a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -87,5 +87,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p);
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
}
[Test]
public void should_not_be_upgradable_if_revision_downgrade_if_propers_are_preferred()
{
_firstFile.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(2));
_parseResultSingle.ParsedMovieInfo.Quality = new QualityModel(Quality.WEBDL1080p);
_upgradeDisk.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
}
}
}

View File

@ -32,6 +32,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
{
var qualityComparer = new QualityModelComparer(profile);
var qualityCompare = qualityComparer.Compare(newQuality?.Quality, currentQuality.Quality);
var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;
if (qualityCompare > 0)
{
@ -45,10 +46,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
return false;
}
var qualityRevisionCompare = 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 &&
qualityRevisionCompare > 0)
{
return true;
}
@ -56,6 +59,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
var currentFormatScore = profile.CalculateCustomFormatScore(currentCustomFormats);
var newFormatScore = profile.CalculateCustomFormatScore(newCustomFormats);
// Reject unless the user does not prefer propers/repacks and it's a revision downgrade.
if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
qualityRevisionCompare < 0)
{
_logger.Debug("Existing item has a better quality revision, skipping");
return false;
}
if (newFormatScore <= currentFormatScore)
{
_logger.Debug("New item's custom formats [{0}] do not improve on [{1}], skipping",