diff --git a/src/NzbDrone.Core/Applications/ApplicationService.cs b/src/NzbDrone.Core/Applications/ApplicationService.cs index 3434c8aa4..5d9e868cf 100644 --- a/src/NzbDrone.Core/Applications/ApplicationService.cs +++ b/src/NzbDrone.Core/Applications/ApplicationService.cs @@ -67,10 +67,11 @@ namespace NzbDrone.Core.Applications public void HandleAsync(ProviderAddedEvent message) { var enabledApps = _applicationsFactory.SyncEnabled(); + var indexer = _indexerFactory.GetInstance((IndexerDefinition)message.Definition); foreach (var app in enabledApps) { - if (ShouldHandleIndexer(app.Definition, message.Definition)) + if (ShouldHandleIndexer(app.Definition, indexer.Definition)) { ExecuteAction(a => a.AddIndexer((IndexerDefinition)message.Definition), app); } @@ -92,8 +93,9 @@ namespace NzbDrone.Core.Applications var enabledApps = _applicationsFactory.SyncEnabled() .Where(n => ((ApplicationDefinition)n.Definition).SyncLevel == ApplicationSyncLevel.FullSync) .ToList(); + var indexer = _indexerFactory.GetInstance((IndexerDefinition)message.Definition); - SyncIndexers(enabledApps, new List { (IndexerDefinition)message.Definition }); + SyncIndexers(enabledApps, new List { (IndexerDefinition)indexer.Definition }); } public void HandleAsync(ApiKeyChangedEvent message) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs index 29d5b757f..67202834e 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs @@ -43,14 +43,12 @@ namespace NzbDrone.Core.Indexers.Newznab public string[] GetBaseUrlFromSettings() { - var baseUrl = ""; - - if (Definition == null || Settings == null || Settings.Categories == null) + if (Definition == null || Settings?.Categories == null) { - return new string[] { baseUrl }; + return new[] { "" }; } - return new string[] { Settings.BaseUrl }; + return new[] { Settings.BaseUrl }; } protected override NewznabSettings GetDefaultBaseUrl(NewznabSettings settings) @@ -62,7 +60,7 @@ namespace NzbDrone.Core.Indexers.Newznab { var caps = new IndexerCapabilities(); - if (Definition == null || Settings == null || Settings.Categories == null) + if (Definition == null || Settings?.Categories == null) { return caps; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs index acdecca56..1e9056f83 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs @@ -34,9 +34,8 @@ namespace NzbDrone.Core.Indexers.Newznab public IndexerCapabilities GetCapabilities(NewznabSettings indexerSettings, ProviderDefinition definition) { var key = indexerSettings.ToJson(); - var capabilities = _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings, definition), TimeSpan.FromDays(7)); - return capabilities; + return _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings, definition), TimeSpan.FromDays(7)); } private IndexerCapabilities FetchCapabilities(NewznabSettings indexerSettings, ProviderDefinition definition) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs index 8d9941ed0..ee4b824fe 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs @@ -45,14 +45,12 @@ namespace NzbDrone.Core.Indexers.Torznab public string[] GetBaseUrlFromSettings() { - var baseUrl = ""; - - if (Definition == null || Settings == null || Settings.Categories == null) + if (Definition == null || Settings?.Categories == null) { - return new string[] { baseUrl }; + return new[] { "" }; } - return new string[] { Settings.BaseUrl }; + return new[] { Settings.BaseUrl }; } protected override TorznabSettings GetDefaultBaseUrl(TorznabSettings settings) @@ -64,7 +62,7 @@ namespace NzbDrone.Core.Indexers.Torznab { var caps = new IndexerCapabilities(); - if (Definition == null || Settings == null || Settings.Categories == null) + if (Definition == null || Settings?.Categories == null) { return caps; }