From 1251e294cdee0ad48c1e9816ab40a8f7a5ccc1da Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 2 Nov 2016 00:02:14 +0100 Subject: [PATCH] Saving settings failed if value was null. --- .../Config/MediaManagementConfigResource.cs | 3 ++- .../Configuration/ConfigServiceFixture.cs | 16 +++++++++++++++- src/NzbDrone.Core/Configuration/ConfigService.cs | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs index a51e8b4d3..097ecc693 100644 --- a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs +++ b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs @@ -44,7 +44,8 @@ namespace NzbDrone.Api.Config SkipFreeSpaceCheckWhenImporting = model.SkipFreeSpaceCheckWhenImporting, CopyUsingHardlinks = model.CopyUsingHardlinks, - EnableMediaInfo = model.EnableMediaInfo, + ExtraFileExtensions = model.ExtraFileExtensions, + EnableMediaInfo = model.EnableMediaInfo }; } } diff --git a/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs b/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs index 6ce968612..8ad51f1e7 100644 --- a/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs @@ -108,5 +108,19 @@ namespace NzbDrone.Core.Test.Configuration keys.Should().OnlyHaveUniqueItems(); } + + [Test] + public void should_ignore_null_properties() + { + Mocker.GetMock() + .Setup(v => v.Get("downloadedepisodesfolder")) + .Returns(new Config { Id = 1, Key = "DownloadedEpisodesFolder", Value = @"C:\test".AsOsAgnostic() }); + + var dict = new Dictionary(); + dict.Add("DownloadedEpisodesFolder", null); + Subject.SaveConfigDictionary(dict); + + Mocker.GetMock().Verify(c => c.Upsert("downloadedepisodesfolder", It.IsAny()), Times.Never()); + } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Configuration/ConfigService.cs b/src/NzbDrone.Core/Configuration/ConfigService.cs index a04dba0e5..e1ac74ee8 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Configuration { object currentValue; allWithDefaults.TryGetValue(configValue.Key, out currentValue); - if (currentValue == null) continue; + if (currentValue == null || configValue.Value == null) continue; var equal = configValue.Value.ToString().Equals(currentValue.ToString());