From 4dec6dd8c4c71425d705b70781af24402c087e96 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 31 May 2021 02:51:08 -0400 Subject: [PATCH] Fixed: Only remove missing if we send all indexers to SyncIndexers --- .../Applications/ApplicationService.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core/Applications/ApplicationService.cs b/src/NzbDrone.Core/Applications/ApplicationService.cs index dda51c258..ef25d5118 100644 --- a/src/NzbDrone.Core/Applications/ApplicationService.cs +++ b/src/NzbDrone.Core/Applications/ApplicationService.cs @@ -35,7 +35,6 @@ namespace NzbDrone.Core.Applications _logger = logger; } - // Sync Indexers on App Add if Sync Enabled public void HandleAsync(ProviderAddedEvent message) { var appDefinition = (ApplicationDefinition)message.Definition; @@ -84,7 +83,7 @@ namespace NzbDrone.Core.Applications var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList(); - SyncIndexers(enabledApps, indexers); + SyncIndexers(enabledApps, indexers, true); } public void HandleAsync(ProviderBulkUpdatedEvent message) @@ -102,10 +101,10 @@ namespace NzbDrone.Core.Applications var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList(); - SyncIndexers(enabledApps, indexers); + SyncIndexers(enabledApps, indexers, true); } - private void SyncIndexers(List applications, List indexers) + private void SyncIndexers(List applications, List indexers, bool removeRemote = false) { foreach (var app in applications) { @@ -148,12 +147,15 @@ namespace NzbDrone.Core.Applications } } - foreach (var mapping in indexerMappings) + if (removeRemote) { - if (!indexers.Any(x => x.Id == mapping.IndexerId)) + foreach (var mapping in indexerMappings) { - _logger.Info("Indexer with the ID {0} was found within {1} but is no longer defined within Prowlarr, this is being removed.", mapping.IndexerId, app.Name); - ExecuteAction(a => a.RemoveIndexer(mapping.IndexerId), app); + if (!indexers.Any(x => x.Id == mapping.IndexerId)) + { + _logger.Info("Indexer with the ID {0} was found within {1} but is no longer defined within Prowlarr, this is being removed.", mapping.IndexerId, app.Name); + ExecuteAction(a => a.RemoveIndexer(mapping.IndexerId), app); + } } } }