1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Fixed: Not importing upgrade for preferred language

Fixes #3605
This commit is contained in:
Mark McDowall 2020-03-05 17:49:06 -08:00
parent e05ceb226c
commit 63e01aff8c
2 changed files with 31 additions and 4 deletions

View File

@ -109,6 +109,24 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_true_if_language_upgrade_for_existing_episodeFile_and_quality_is_same_but_lower_revision()
{
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
.All()
.With(e => e.EpisodeFileId = 1)
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
new EpisodeFile
{
Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language = Language.English
}))
.Build()
.ToList();
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_false_if_language_upgrade_for_existing_episodeFile_and_quality_is_worse()
{
@ -251,7 +269,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
new EpisodeFile
{
Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 2))
Quality = new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language = Language.Spanish
}))
.Build()
.ToList();

View File

@ -37,6 +37,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
}
var qualityCompare = qualityComparer.Compare(localEpisode.Quality.Quality, episodeFile.Quality.Quality);
var languageCompare = languageComparer.Compare(localEpisode.Language, episodeFile.Language);
if (qualityCompare < 0)
{
@ -44,14 +45,21 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
return Decision.Reject("Not an upgrade for existing episode file(s)");
}
if (qualityCompare == 0 && downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
// Same quality, is not a language upgrade, propers/repacks are preferred and it is not a revision update
// This will allow language upgrades of a lower revision to be imported, which are allowed to be grabbed,
// they just don't import automatically.
if (qualityCompare == 0 &&
languageCompare <= 0 &&
downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
localEpisode.Quality.Revision.CompareTo(episodeFile.Quality.Revision) < 0)
{
_logger.Debug("This file isn't a quality upgrade for all episodes. Skipping {0}", localEpisode.Path);
_logger.Debug("This file isn't a quality revision upgrade for all episodes. Skipping {0}", localEpisode.Path);
return Decision.Reject("Not an upgrade for existing episode file(s)");
}
if (languageComparer.Compare(localEpisode.Language, episodeFile.Language) < 0 && qualityCompare == 0)
if (languageCompare < 0 && qualityCompare == 0)
{
_logger.Debug("This file isn't a language upgrade for all episodes. Skipping {0}", localEpisode.Path);
return Decision.Reject("Not an upgrade for existing episode file(s)");