Check if NzbGet KeepHistory value is set too high instead of only checking for 0.

This commit is contained in:
Taloth Saldono 2017-06-25 16:39:10 +02:00
parent 60231fbcae
commit f46a576df5
2 changed files with 25 additions and 1 deletions

View File

@ -414,5 +414,20 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
error.IsValid.Should().Be(expected); error.IsValid.Should().Be(expected);
} }
[TestCase("0", false)]
[TestCase("1", true)]
[TestCase(" 7", false)]
[TestCase("5000000", false)]
public void should_test_keephistory(string keephistory, bool expected)
{
Mocker.GetMock<INzbgetProxy>()
.Setup(v => v.GetConfig(It.IsAny<NzbgetSettings>()))
.Returns(new Dictionary<string, string> { { "KeepHistory", keephistory } });
var error = Subject.Test();
error.IsValid.Should().Be(expected);
}
} }
} }

View File

@ -297,7 +297,8 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var keepHistory = config.GetValueOrDefault("KeepHistory"); var keepHistory = config.GetValueOrDefault("KeepHistory");
if (keepHistory == "0") int value;
if (int.TryParse(keepHistory, out value) || value == 0)
{ {
return new NzbDroneValidationFailure(string.Empty, "NzbGet setting KeepHistory should be greater than 0") return new NzbDroneValidationFailure(string.Empty, "NzbGet setting KeepHistory should be greater than 0")
{ {
@ -305,6 +306,14 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
DetailedDescription = "NzbGet setting KeepHistory is set to 0. Which prevents Sonarr from seeing completed downloads." DetailedDescription = "NzbGet setting KeepHistory is set to 0. Which prevents Sonarr from seeing completed downloads."
}; };
} }
else if (value > 25000)
{
return new NzbDroneValidationFailure(string.Empty, "NzbGet setting KeepHistory should be less than 25000")
{
InfoLink = string.Format("http://{0}:{1}/", Settings.Host, Settings.Port),
DetailedDescription = "NzbGet setting KeepHistory is set too high."
};
}
return null; return null;
} }