From 045f1a85dfa12482c9c93a1d3dd200ddc84fb7ba Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 14 May 2023 20:01:55 +0300 Subject: [PATCH] Fixed: Prevent unknown settings implementation from failing to deserialize (cherry picked from commit 0e2cc7851f556e928e52bb2886c7d60c13b0741e) Log removal of invalid definitions as warnings (cherry picked from commit 3d61719a2cc9c87ac3c92b5358bb5034aed4c2ff) (cherry picked from commit 498722b240c17d310863ed604c441a9c507ddcd6) Closes #2491 --- src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs | 3 +-- src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs index 5220ecd1c..b81b64446 100644 --- a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs +++ b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs @@ -169,14 +169,13 @@ namespace NzbDrone.Core.ThingiProvider definition.Message = provider.Message; } - //TODO: Remove providers even if the ConfigContract can't be deserialized (this will fail to remove providers if the settings can't be deserialized). private void RemoveMissingImplementations() { var storedProvider = _providerRepository.All(); foreach (var invalidDefinition in storedProvider.Where(def => GetImplementation(def) == null)) { - _logger.Debug("Removing {0} ", invalidDefinition.Name); + _logger.Warn("Removing {0}", invalidDefinition.Name); _providerRepository.Delete(invalidDefinition); } } diff --git a/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs b/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs index 626dafa19..d814d79c4 100644 --- a/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs +++ b/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Core.ThingiProvider var item = parser(reader); var impType = typeof(IProviderConfig).Assembly.FindTypeByName(item.ConfigContract); - if (body.IsNullOrWhiteSpace()) + if (body.IsNullOrWhiteSpace() || impType == null) { item.Settings = NullConfig.Instance; }