New: Only sync indexers with matching app tags

pull/993/head
Qstick 3 years ago
parent 1a71375c3f
commit af50a1d3a8

@ -9,6 +9,7 @@ using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.ThingiProvider.Events; using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.Applications namespace NzbDrone.Core.Applications
@ -68,10 +69,13 @@ namespace NzbDrone.Core.Applications
var enabledApps = _applicationsFactory.SyncEnabled(); var enabledApps = _applicationsFactory.SyncEnabled();
foreach (var app in enabledApps) foreach (var app in enabledApps)
{
if (ShouldHandleIndexer(app.Definition, message.Definition))
{ {
ExecuteAction(a => a.AddIndexer((IndexerDefinition)message.Definition), app); ExecuteAction(a => a.AddIndexer((IndexerDefinition)message.Definition), app);
} }
} }
}
public void HandleAsync(ProviderDeletedEvent<IIndexer> message) public void HandleAsync(ProviderDeletedEvent<IIndexer> message)
{ {
@ -157,14 +161,14 @@ namespace NzbDrone.Core.Applications
if (indexerMappings.Any(x => x.IndexerId == definition.Id)) 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); ExecuteAction(a => a.UpdateIndexer(definition), app);
} }
} }
else else
{ {
if (indexer.Enable) if (indexer.Enable && ShouldHandleIndexer(app.Definition, indexer))
{ {
ExecuteAction(a => a.AddIndexer(definition), app); 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<IApplication> applicationAction, IApplication application) private void ExecuteAction(Action<IApplication> applicationAction, IApplication application)
{ {
try try

Loading…
Cancel
Save