Fixed: Imports when custom format is a downgrade, but file is an upgrade

pull/5462/head
Mark McDowall 2 years ago
parent 5d09b84b05
commit cef6d5a99a

@ -488,6 +488,45 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_true_if_not_upgrade_to_custom_format_score_but_is_upgrade_to_quality()
{
var episodeFileCustomFormats = Builder<CustomFormat>.CreateListOfSize(1).Build().ToList();
var episodeFile = new EpisodeFile
{
Quality = new QualityModel(Quality.Bluray720p)
};
_series.QualityProfile.Value.FormatItems = episodeFileCustomFormats.Select(c => new ProfileFormatItem
{
Format = c,
Score = 50
})
.ToList();
Mocker.GetMock<IConfigService>()
.Setup(s => s.DownloadPropersAndRepacks)
.Returns(ProperDownloadTypes.DoNotPrefer);
Mocker.GetMock<ICustomFormatCalculationService>()
.Setup(s => s.ParseCustomFormat(episodeFile))
.Returns(episodeFileCustomFormats);
_localEpisode.Quality = new QualityModel(Quality.Bluray1080p);
_localEpisode.CustomFormats = Builder<CustomFormat>.CreateListOfSize(1).Build().ToList();
_localEpisode.CustomFormatScore = 20;
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
.All()
.With(e => e.EpisodeFileId = 1)
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(episodeFile))
.Build()
.ToList();
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_false_if_not_upgrade_to_custom_format_score()
{

@ -62,7 +62,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
var currentFormats = _formatService.ParseCustomFormat(episodeFile);
var currentScore = qualityProfile.CalculateCustomFormatScore(currentFormats);
if (localEpisode.CustomFormatScore < currentScore)
if (qualityCompare == 0 && localEpisode.CustomFormatScore < currentScore)
{
_logger.Debug("New file's custom formats [{0}] do not improve on [{1}], skipping",
localEpisode.CustomFormats.ConcatToString(),

Loading…
Cancel
Save