From a72b856fb80457ec200d262ec01c441660440d31 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Tue, 13 Sep 2016 22:58:14 +0200 Subject: [PATCH] Fixed: Added config validation to ensure NzbGet KeepHistory isn't set to 0. --- .../Download/Clients/Nzbget/Nzbget.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index c21a4bb9f..8a3ae8884 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -272,6 +272,7 @@ protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); failures.AddIfNotNull(TestCategory()); + failures.AddIfNotNull(TestSettings()); } private ValidationFailure TestConnection() @@ -315,7 +316,24 @@ private ValidationFailure TestCategory() return null; } - // Javascript doesn't support 64 bit integers natively so json officially doesn't either. + private ValidationFailure TestSettings() + { + var config = _proxy.GetConfig(Settings); + + var keepHistory = config.GetValueOrDefault("KeepHistory"); + if (keepHistory == "0") + { + return new NzbDroneValidationFailure(string.Empty, "NzbGet setting KeepHistory should be greater than 0") + { + InfoLink = string.Format("http://{0}:{1}/", Settings.Host, Settings.Port), + DetailedDescription = "NzbGet setting KeepHistory is set to 0. Which prevents Sonarr from seeing completed downloads." + }; + } + + return null; + } + + // Javascript doesn't support 64 bit integers natively so json officially doesn't either. // NzbGet api thus sends it in two 32 bit chunks. Here we join the two chunks back together. // Simplified decimal example: "42" splits into "4" and "2". To join them I shift (<<) the "4" 1 digit to the left = "40". combine it with "2". which becomes "42" again. private long MakeInt64(uint high, uint low) @@ -327,4 +345,4 @@ private long MakeInt64(uint high, uint low) return result; } } -} \ No newline at end of file +}