mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 13:10:13 -07:00
Fixed: Profiles with upgrades disabled incorrectly allowing upgrades in some cases
Closes #2649
This commit is contained in:
parent
aa5869c498
commit
0592f35aee
3 changed files with 27 additions and 6 deletions
|
@ -19,7 +19,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
new QualityProfile
|
new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.MP3_256.Id,
|
Cutoff = Quality.MP3_256.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
UpgradeAllowed = true
|
||||||
},
|
},
|
||||||
new List<QualityModel> { new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
new List<QualityModel> { new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||||
new List<CustomFormat>()).Should().BeTrue();
|
new List<CustomFormat>()).Should().BeTrue();
|
||||||
|
@ -32,7 +33,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
new QualityProfile
|
new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.MP3_256.Id,
|
Cutoff = Quality.MP3_256.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
UpgradeAllowed = true
|
||||||
},
|
},
|
||||||
new List<QualityModel> { new QualityModel(Quality.MP3_256, new Revision(version: 2)) },
|
new List<QualityModel> { new QualityModel(Quality.MP3_256, new Revision(version: 2)) },
|
||||||
new List<CustomFormat>()).Should().BeFalse();
|
new List<CustomFormat>()).Should().BeFalse();
|
||||||
|
@ -45,7 +47,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
new QualityProfile
|
new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.MP3_256.Id,
|
Cutoff = Quality.MP3_256.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
UpgradeAllowed = true
|
||||||
},
|
},
|
||||||
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||||
new List<CustomFormat>()).Should().BeFalse();
|
new List<CustomFormat>()).Should().BeFalse();
|
||||||
|
@ -58,7 +61,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
new QualityProfile
|
new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.MP3_320.Id,
|
Cutoff = Quality.MP3_320.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
UpgradeAllowed = true
|
||||||
},
|
},
|
||||||
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 1)) },
|
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 1)) },
|
||||||
new List<CustomFormat>(),
|
new List<CustomFormat>(),
|
||||||
|
@ -72,7 +76,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
new QualityProfile
|
new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.MP3_320.Id,
|
Cutoff = Quality.MP3_320.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
UpgradeAllowed = true
|
||||||
},
|
},
|
||||||
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||||
new List<CustomFormat>(),
|
new List<CustomFormat>(),
|
||||||
|
@ -86,6 +91,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
{
|
{
|
||||||
Cutoff = Quality.MP3_320.Id,
|
Cutoff = Quality.MP3_320.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
UpgradeAllowed = true
|
||||||
};
|
};
|
||||||
|
|
||||||
Subject.CutoffNotMet(
|
Subject.CutoffNotMet(
|
||||||
|
|
|
@ -99,7 +99,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
|
|
||||||
public bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null)
|
public bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null)
|
||||||
{
|
{
|
||||||
var cutoffCompare = new QualityModelComparer(profile).Compare(currentQuality.Quality.Id, profile.Cutoff);
|
var cutoff = profile.UpgradeAllowed ? profile.Cutoff : profile.FirstAllowedQuality().Id;
|
||||||
|
var cutoffCompare = new QualityModelComparer(profile).Compare(currentQuality.Quality.Id, cutoff);
|
||||||
|
|
||||||
if (cutoffCompare < 0)
|
if (cutoffCompare < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,20 @@ namespace NzbDrone.Core.Profiles.Qualities
|
||||||
public List<ProfileFormatItem> FormatItems { get; set; }
|
public List<ProfileFormatItem> FormatItems { get; set; }
|
||||||
public List<QualityProfileQualityItem> Items { get; set; }
|
public List<QualityProfileQualityItem> Items { get; set; }
|
||||||
|
|
||||||
|
public Quality FirstAllowedQuality()
|
||||||
|
{
|
||||||
|
var firstAllowed = Items.First(q => q.Allowed);
|
||||||
|
|
||||||
|
if (firstAllowed.Quality != null)
|
||||||
|
{
|
||||||
|
return firstAllowed.Quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returning any item from the group will work,
|
||||||
|
// returning the first because it's the true first quality.
|
||||||
|
return firstAllowed.Items.First().Quality;
|
||||||
|
}
|
||||||
|
|
||||||
public Quality LastAllowedQuality()
|
public Quality LastAllowedQuality()
|
||||||
{
|
{
|
||||||
var lastAllowed = Items.Last(q => q.Allowed);
|
var lastAllowed = Items.Last(q => q.Allowed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue