From af50a1d3a8405e8d79a82dd9535909cb3f4213f5 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 1 May 2022 20:10:27 -0500 Subject: [PATCH] New: Only sync indexers with matching app tags --- .../Applications/ApplicationService.cs | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Applications/ApplicationService.cs b/src/NzbDrone.Core/Applications/ApplicationService.cs index f3a80161c..a6a20f5dc 100644 --- a/src/NzbDrone.Core/Applications/ApplicationService.cs +++ b/src/NzbDrone.Core/Applications/ApplicationService.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.Configuration.Events; using NzbDrone.Core.Indexers; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider.Events; namespace NzbDrone.Core.Applications @@ -69,7 +70,10 @@ namespace NzbDrone.Core.Applications foreach (var app in enabledApps) { - ExecuteAction(a => a.AddIndexer((IndexerDefinition)message.Definition), app); + if (ShouldHandleIndexer(app.Definition, message.Definition)) + { + ExecuteAction(a => a.AddIndexer((IndexerDefinition)message.Definition), app); + } } } @@ -157,14 +161,14 @@ namespace NzbDrone.Core.Applications if (indexerMappings.Any(x => x.IndexerId == definition.Id)) { - if (((ApplicationDefinition)app.Definition).SyncLevel == ApplicationSyncLevel.FullSync) + if (((ApplicationDefinition)app.Definition).SyncLevel == ApplicationSyncLevel.FullSync && ShouldHandleIndexer(app.Definition, indexer)) { ExecuteAction(a => a.UpdateIndexer(definition), app); } } else { - if (indexer.Enable) + if (indexer.Enable && ShouldHandleIndexer(app.Definition, indexer)) { ExecuteAction(a => a.AddIndexer(definition), app); } @@ -187,6 +191,24 @@ namespace NzbDrone.Core.Applications } } + private bool ShouldHandleIndexer(ProviderDefinition app, ProviderDefinition indexer) + { + if (app.Tags.Empty()) + { + _logger.Debug("No tags set for this application."); + return true; + } + + if (app.Tags.Intersect(indexer.Tags).Any()) + { + _logger.Debug("Application and indexer have one or more intersecting tags."); + return true; + } + + _logger.Debug("{0} does not have any intersecting tags with {1}. Indexer will not be synced", app.Name, indexer.Name); + return false; + } + private void ExecuteAction(Action applicationAction, IApplication application) { try