mirror of
https://github.com/Radarr/Radarr
synced 2024-12-21 23:42:23 +00:00
Fixed: Custom Format score bypassing upgrades not being allowed
(cherry picked from commit ebe23104d4b29a3c900a982fb84e75c27ed531ab) Co-authored-by: CeruleanRed <toni.suta@gmail.com>
This commit is contained in:
parent
c81b2e80ee
commit
f1d7c56d94
7 changed files with 57 additions and 13 deletions
|
@ -5,6 +5,7 @@
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
|
@ -337,5 +338,42 @@ public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_f
|
|||
|
||||
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_and_is_revision_upgrade()
|
||||
{
|
||||
var customFormat = new CustomFormat("My Format", new ResolutionSpecification { Value = (int)Resolution.R1080p }) { Id = 1 };
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.DoNotPrefer);
|
||||
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.SDTV.Id,
|
||||
MinFormatScore = 0,
|
||||
CutoffFormatScore = 10000,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
FormatItems = CustomFormatsTestHelpers.GetSampleFormatItems("My Format"),
|
||||
UpgradeAllowed = false
|
||||
});
|
||||
|
||||
_parseResultSingle.Movie.QualityProfile.FormatItems = new List<ProfileFormatItem>
|
||||
{
|
||||
new ProfileFormatItem
|
||||
{
|
||||
Format = customFormat,
|
||||
Score = 50
|
||||
}
|
||||
};
|
||||
|
||||
GivenFileQuality(new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)));
|
||||
GivenNewQuality(new QualityModel(Quality.WEBDL1080p, new Revision(version: 2)));
|
||||
|
||||
GivenOldCustomFormats(new List<CustomFormat>());
|
||||
GivenNewCustomFormats(new List<CustomFormat> { customFormat });
|
||||
|
||||
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public void should_return_false_if_release_and_existing_file_are_the_same()
|
|||
new List<CustomFormat>(),
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
|
||||
new List<CustomFormat>())
|
||||
.Should().Be(UpgradeableRejectReason.CustomFormatScore);
|
||||
.Should().Be(UpgradeableRejectReason.UpgradesNotAllowed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -96,17 +96,9 @@ public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCrit
|
|||
|
||||
case UpgradeableRejectReason.MinCustomFormatScore:
|
||||
return Decision.Reject("Release in queue has Custom Format score within Custom Format score increment: {0}", qualityProfile.MinUpgradeFormatScore);
|
||||
}
|
||||
|
||||
_logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteMovie.ParsedMovieInfo.Quality);
|
||||
|
||||
if (!_upgradableSpecification.IsUpgradeAllowed(subject.Movie.QualityProfile,
|
||||
remoteMovie.ParsedMovieInfo.Quality,
|
||||
remoteMovie.CustomFormats,
|
||||
subject.ParsedMovieInfo.Quality,
|
||||
subject.CustomFormats))
|
||||
{
|
||||
return Decision.Reject("Another release is queued and the Quality profile does not allow upgrades");
|
||||
case UpgradeableRejectReason.UpgradesNotAllowed:
|
||||
return Decision.Reject("Release in queue and Quality Profile '{0}' does not allow upgrades", qualityProfile.Name);
|
||||
}
|
||||
|
||||
if (_upgradableSpecification.IsRevisionUpgrade(remoteMovie.ParsedMovieInfo.Quality, subject.ParsedMovieInfo.Quality))
|
||||
|
|
|
@ -107,6 +107,9 @@ public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase se
|
|||
|
||||
case UpgradeableRejectReason.MinCustomFormatScore:
|
||||
return Decision.Reject("{0} grab event in history has Custom Format score within Custom Format score increment: {1}", rejectionSubject, qualityProfile.MinUpgradeFormatScore);
|
||||
|
||||
case UpgradeableRejectReason.UpgradesNotAllowed:
|
||||
return Decision.Reject("{0} grab event in history and Quality Profile '{1}' does not allow upgrades", rejectionSubject, qualityProfile.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,13 @@ public UpgradeableRejectReason IsUpgradable(QualityProfile qualityProfile, Quali
|
|||
return UpgradeableRejectReason.None;
|
||||
}
|
||||
|
||||
if (!qualityProfile.UpgradeAllowed)
|
||||
{
|
||||
_logger.Debug("Quality profile '{0}' does not allow upgrading. Skipping.", qualityProfile.Name);
|
||||
|
||||
return UpgradeableRejectReason.UpgradesNotAllowed;
|
||||
}
|
||||
|
||||
// Reject unless the user does not prefer propers/repacks and it's a revision downgrade.
|
||||
if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
|
||||
qualityRevisionCompare < 0)
|
||||
|
@ -86,7 +93,7 @@ public UpgradeableRejectReason IsUpgradable(QualityProfile qualityProfile, Quali
|
|||
return UpgradeableRejectReason.CustomFormatScore;
|
||||
}
|
||||
|
||||
if (qualityProfile.UpgradeAllowed && currentFormatScore >= qualityProfile.CutoffFormatScore)
|
||||
if (currentFormatScore >= qualityProfile.CutoffFormatScore)
|
||||
{
|
||||
_logger.Debug("Existing item meets cut-off for custom formats, skipping. Existing: [{0}] ({1}). Cutoff score: {2}",
|
||||
currentCustomFormats.ConcatToString(),
|
||||
|
|
|
@ -83,6 +83,9 @@ public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase se
|
|||
|
||||
case UpgradeableRejectReason.MinCustomFormatScore:
|
||||
return Decision.Reject("Existing file on disk has Custom Format score within Custom Format score increment: {0}", qualityProfile.MinUpgradeFormatScore);
|
||||
|
||||
case UpgradeableRejectReason.UpgradesNotAllowed:
|
||||
return Decision.Reject("Existing file on disk and Quality Profile '{0}' does not allow upgrades", qualityProfile.Name);
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
|
|
|
@ -8,6 +8,7 @@ public enum UpgradeableRejectReason
|
|||
QualityCutoff,
|
||||
CustomFormatScore,
|
||||
CustomFormatCutoff,
|
||||
MinCustomFormatScore
|
||||
MinCustomFormatScore,
|
||||
UpgradesNotAllowed
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue