Fixed: Only remove missing if we send all indexers to SyncIndexers

This commit is contained in:
Qstick
2021-05-31 02:51:08 -04:00
parent 91b23e6413
commit 4dec6dd8c4

View File

@@ -35,7 +35,6 @@ namespace NzbDrone.Core.Applications
_logger = logger; _logger = logger;
} }
// Sync Indexers on App Add if Sync Enabled
public void HandleAsync(ProviderAddedEvent<IApplication> message) public void HandleAsync(ProviderAddedEvent<IApplication> message)
{ {
var appDefinition = (ApplicationDefinition)message.Definition; var appDefinition = (ApplicationDefinition)message.Definition;
@@ -84,7 +83,7 @@ namespace NzbDrone.Core.Applications
var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList(); var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList();
SyncIndexers(enabledApps, indexers); SyncIndexers(enabledApps, indexers, true);
} }
public void HandleAsync(ProviderBulkUpdatedEvent<IIndexer> message) public void HandleAsync(ProviderBulkUpdatedEvent<IIndexer> message)
@@ -102,10 +101,10 @@ namespace NzbDrone.Core.Applications
var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList(); var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList();
SyncIndexers(enabledApps, indexers); SyncIndexers(enabledApps, indexers, true);
} }
private void SyncIndexers(List<IApplication> applications, List<IndexerDefinition> indexers) private void SyncIndexers(List<IApplication> applications, List<IndexerDefinition> indexers, bool removeRemote = false)
{ {
foreach (var app in applications) foreach (var app in applications)
{ {
@@ -148,6 +147,8 @@ namespace NzbDrone.Core.Applications
} }
} }
if (removeRemote)
{
foreach (var mapping in indexerMappings) foreach (var mapping in indexerMappings)
{ {
if (!indexers.Any(x => x.Id == mapping.IndexerId)) if (!indexers.Any(x => x.Id == mapping.IndexerId))
@@ -158,6 +159,7 @@ namespace NzbDrone.Core.Applications
} }
} }
} }
}
private void ExecuteAction(Action<IApplication> applicationAction, IApplication application) private void ExecuteAction(Action<IApplication> applicationAction, IApplication application)
{ {