1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-23 02:05:27 +02:00

Fixed: Custom Format upgrading not respecting 'Upgrades Allowed'

This commit is contained in:
Mark McDowall 2024-11-24 15:20:44 -08:00
parent dcbef6b7b7
commit 91c5e6f122
2 changed files with 36 additions and 1 deletions

View File

@ -11,6 +11,7 @@
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Profiles.Qualities;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.CustomFormats;
@ -365,5 +366,38 @@ public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_c
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
}
[Test]
public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_format_cutoff_is_above_current_score()
{
var customFormat = new CustomFormat("My Format", new ResolutionSpecification { Value = (int)Resolution.R1080p }) { Id = 1 };
GivenProfile(new QualityProfile
{
Cutoff = Quality.SDTV.Id,
MinFormatScore = 0,
CutoffFormatScore = 10000,
Items = Qualities.QualityFixture.GetDefaultQualities(),
FormatItems = CustomFormatsTestHelpers.GetSampleFormatItems("My Format"),
UpgradeAllowed = false
});
_parseResultSingle.Series.QualityProfile.Value.FormatItems = new List<ProfileFormatItem>
{
new ProfileFormatItem
{
Format = customFormat,
Score = 50
}
};
GivenFileQuality(new QualityModel(Quality.WEBDL1080p));
GivenNewQuality(new QualityModel(Quality.WEBDL1080p));
GivenOldCustomFormats(new List<CustomFormat>());
GivenNewCustomFormats(new List<CustomFormat> { customFormat });
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
}
}
}

View File

@ -135,8 +135,9 @@ public bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQual
private bool CustomFormatCutoffNotMet(QualityProfile profile, List<CustomFormat> currentFormats)
{
var score = profile.CalculateCustomFormatScore(currentFormats);
var cutoff = profile.UpgradeAllowed ? profile.CutoffFormatScore : profile.MinFormatScore;
return score < profile.CutoffFormatScore;
return score < cutoff;
}
public bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, List<CustomFormat> currentFormats, QualityModel newQuality = null)