New: Improve logging when checking if release is an upgrade for an existing file

This commit is contained in:
Mark McDowall 2019-07-01 00:44:37 -07:00
parent 0f8dee7011
commit 093ed23140
2 changed files with 33 additions and 1 deletions

View File

@ -164,5 +164,31 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
NoPreferredWordScore)
.Should().BeFalse();
}
[Test]
public void should_return_false_if_release_and_existing_file_are_the_same()
{
var profile = new QualityProfile
{
Items = Qualities.QualityFixture.GetDefaultQualities(),
};
var langProfile = new LanguageProfile
{
Languages = LanguageFixture.GetDefaultLanguages(),
Cutoff = Language.English
};
Subject.IsUpgradable(
profile,
langProfile,
new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
Language.English,
NoPreferredWordScore,
new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
Language.English,
NoPreferredWordScore)
.Should().BeFalse();
}
}
}

View File

@ -30,6 +30,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
private bool IsPreferredWordUpgradable(int currentScore, int newScore)
{
_logger.Debug("Comparing preferred word score. Current: {0} New: {1}", currentScore, newScore);
return newScore > currentScore;
}
@ -40,6 +42,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (qualityCompare > 0)
{
_logger.Debug("New item has a better quality");
return true;
}
@ -54,6 +57,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (_configService.DownloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
newQuality?.Revision.CompareTo(currentQuality.Revision) > 0)
{
_logger.Debug("New item has a better quality revision");
return true;
}
@ -61,6 +65,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
if (languageCompare > 0)
{
_logger.Debug("New item has a more preferred language");
return true;
}
@ -69,13 +74,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
_logger.Debug("Existing item has better language, skipping");
return false;
}
if (!IsPreferredWordUpgradable(currentScore, newScore))
{
_logger.Debug("Existing item has a better preferred word score, skipping");
return false;
}
_logger.Debug("New item has a better preferred word score");
return true;
}