mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-23 02:05:27 +02:00
Fixed: Custom Format score bypassing upgrades not being allowed
This commit is contained in:
parent
e8c3aa20bd
commit
ebe23104d4
@ -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.Languages;
|
||||
@ -399,5 +400,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.Series.QualityProfile.Value.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public void should_return_false_if_proper_and_autoDownloadPropers_is_do_not_pref
|
||||
new List<CustomFormat>(),
|
||||
new QualityModel(Quality.DVD, new Revision(version: 2)),
|
||||
new List<CustomFormat>())
|
||||
.Should().Be(UpgradeableRejectReason.CustomFormatScore);
|
||||
.Should().Be(UpgradeableRejectReason.UpgradesNotAllowed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -107,7 +107,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]
|
||||
|
@ -20,6 +20,7 @@ public enum DownloadRejectionReason
|
||||
HistoryCustomFormatCutoffMet,
|
||||
HistoryCustomFormatScore,
|
||||
HistoryCustomFormatScoreIncrement,
|
||||
HistoryUpgradesNotAllowed,
|
||||
NoMatchingTag,
|
||||
PropersDisabled,
|
||||
ProperForOldFile,
|
||||
@ -53,7 +54,7 @@ public enum DownloadRejectionReason
|
||||
QueueCustomFormatCutoffMet,
|
||||
QueueCustomFormatScore,
|
||||
QueueCustomFormatScoreIncrement,
|
||||
QueueNoUpgrades,
|
||||
QueueUpgradesNotAllowed,
|
||||
QueuePropersDisabled,
|
||||
Raw,
|
||||
MustContainMissing,
|
||||
@ -72,4 +73,5 @@ public enum DownloadRejectionReason
|
||||
DiskCustomFormatCutoffMet,
|
||||
DiskCustomFormatScore,
|
||||
DiskCustomFormatScoreIncrement,
|
||||
DiskUpgradesNotAllowed
|
||||
}
|
||||
|
@ -95,17 +95,9 @@ public DownloadSpecDecision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaB
|
||||
|
||||
case UpgradeableRejectReason.MinCustomFormatScore:
|
||||
return DownloadSpecDecision.Reject(DownloadRejectionReason.QueueCustomFormatScoreIncrement, "Release in queue has Custom Format score within Custom Format score increment: {0}", qualityProfile.MinUpgradeFormatScore);
|
||||
}
|
||||
|
||||
_logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteEpisode.ParsedEpisodeInfo.Quality);
|
||||
|
||||
if (!_upgradableSpecification.IsUpgradeAllowed(subject.Series.QualityProfile,
|
||||
remoteEpisode.ParsedEpisodeInfo.Quality,
|
||||
queuedItemCustomFormats,
|
||||
subject.ParsedEpisodeInfo.Quality,
|
||||
subject.CustomFormats))
|
||||
{
|
||||
return DownloadSpecDecision.Reject(DownloadRejectionReason.QueueNoUpgrades, "Another release is queued and the Quality profile does not allow upgrades");
|
||||
case UpgradeableRejectReason.UpgradesNotAllowed:
|
||||
return DownloadSpecDecision.Reject(DownloadRejectionReason.QueueUpgradesNotAllowed, "Release in queue and Quality Profile '{0}' does not allow upgrades", qualityProfile.Name);
|
||||
}
|
||||
|
||||
if (_upgradableSpecification.IsRevisionUpgrade(remoteEpisode.ParsedEpisodeInfo.Quality, subject.ParsedEpisodeInfo.Quality))
|
||||
|
@ -111,6 +111,9 @@ public virtual DownloadSpecDecision IsSatisfiedBy(RemoteEpisode subject, SearchC
|
||||
|
||||
case UpgradeableRejectReason.MinCustomFormatScore:
|
||||
return DownloadSpecDecision.Reject(DownloadRejectionReason.HistoryCustomFormatScoreIncrement, "{0} grab event in history has Custom Format score within Custom Format score increment: {1}", rejectionSubject, qualityProfile.MinUpgradeFormatScore);
|
||||
|
||||
case UpgradeableRejectReason.UpgradesNotAllowed:
|
||||
return DownloadSpecDecision.Reject(DownloadRejectionReason.HistoryUpgradesNotAllowed, "{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(),
|
||||
|
@ -81,6 +81,9 @@ public virtual DownloadSpecDecision IsSatisfiedBy(RemoteEpisode subject, SearchC
|
||||
|
||||
case UpgradeableRejectReason.MinCustomFormatScore:
|
||||
return DownloadSpecDecision.Reject(DownloadRejectionReason.DiskCustomFormatScoreIncrement, "Existing file on disk has Custom Format score within Custom Format score increment: {0}", qualityProfile.MinUpgradeFormatScore);
|
||||
|
||||
case UpgradeableRejectReason.UpgradesNotAllowed:
|
||||
return DownloadSpecDecision.Reject(DownloadRejectionReason.DiskUpgradesNotAllowed, "Existing file on disk and Quality Profile '{0}' does not allow upgrades", qualityProfile.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ public enum UpgradeableRejectReason
|
||||
QualityCutoff,
|
||||
CustomFormatScore,
|
||||
CustomFormatCutoff,
|
||||
MinCustomFormatScore
|
||||
MinCustomFormatScore,
|
||||
UpgradesNotAllowed
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user