mirror of
https://github.com/Sonarr/Sonarr
synced 2025-01-03 05:35:29 +00:00
Fixed: Custom Format upgrading not respecting 'Upgrades Allowed'
This commit is contained in:
parent
dcbef6b7b7
commit
91c5e6f122
2 changed files with 36 additions and 1 deletions
|
@ -11,6 +11,7 @@ using NzbDrone.Core.Languages;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Profiles;
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Test.CustomFormats;
|
using NzbDrone.Core.Test.CustomFormats;
|
||||||
|
@ -365,5 +366,38 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
|
||||||
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,8 +135,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
private bool CustomFormatCutoffNotMet(QualityProfile profile, List<CustomFormat> currentFormats)
|
private bool CustomFormatCutoffNotMet(QualityProfile profile, List<CustomFormat> currentFormats)
|
||||||
{
|
{
|
||||||
var score = profile.CalculateCustomFormatScore(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)
|
public bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, List<CustomFormat> currentFormats, QualityModel newQuality = null)
|
||||||
|
|
Loading…
Reference in a new issue