Filter enabled indexer proxies in Active

pull/1708/head
Bogdan 2 years ago
parent b0c2b9119b
commit 8c0bc9ab4e

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
@ -16,5 +17,10 @@ namespace NzbDrone.Core.IndexerProxies
: base(providerRepository, providers, container, eventAggregator, logger) : base(providerRepository, providers, container, eventAggregator, logger)
{ {
} }
protected override List<IndexerProxyDefinition> Active()
{
return All().Where(c => c.Enable && c.Settings.Validate().IsValid).ToList();
}
} }
} }

@ -52,23 +52,14 @@ namespace NzbDrone.Core.Indexers
private IIndexerProxy GetProxy(ProviderDefinition definition) private IIndexerProxy GetProxy(ProviderDefinition definition)
{ {
//Skip DB call if no tags on the indexers // Skip DB call if no tags on the indexers
if (definition.Tags.Count == 0 && definition.Id > 0) if (definition.Tags.Count == 0 && definition.Id > 0)
{ {
return null; return null;
} }
var proxies = _indexerProxyFactory.GetAvailableProviders(); var proxies = _indexerProxyFactory.GetAvailableProviders();
IIndexerProxy selectedProxy = null; var selectedProxy = proxies.FirstOrDefault(proxy => definition.Tags.Intersect(proxy.Definition.Tags).Any());
foreach (var proxy in proxies)
{
if (definition.Tags.Intersect(proxy.Definition.Tags).Any())
{
selectedProxy = proxy;
break;
}
}
if (selectedProxy == null && definition.Id == 0) if (selectedProxy == null && definition.Id == 0)
{ {

Loading…
Cancel
Save