Newznab indexers are tested before creating
This commit is contained in:
parent
1689aa4f64
commit
03149b1396
|
@ -16,12 +16,14 @@ namespace NzbDrone.Core.Indexers
|
|||
{
|
||||
private readonly IIndexerRepository _providerRepository;
|
||||
private readonly IEnumerable<IIndexer> _providers;
|
||||
private readonly INewznabTestService _newznabTestService;
|
||||
|
||||
public IndexerFactory(IIndexerRepository providerRepository, IEnumerable<IIndexer> providers, IContainer container, Logger logger)
|
||||
public IndexerFactory(IIndexerRepository providerRepository, IEnumerable<IIndexer> providers, IContainer container, INewznabTestService newznabTestService, Logger logger)
|
||||
: base(providerRepository, providers, container, logger)
|
||||
{
|
||||
_providerRepository = providerRepository;
|
||||
_providers = providers;
|
||||
_newznabTestService = newznabTestService;
|
||||
}
|
||||
|
||||
protected override void InitializeProviders()
|
||||
|
@ -43,5 +45,16 @@ namespace NzbDrone.Core.Indexers
|
|||
{
|
||||
return base.Active().Where(c => c.Enable).ToList();
|
||||
}
|
||||
|
||||
public override IndexerDefinition Create(IndexerDefinition definition)
|
||||
{
|
||||
if (definition.Implementation == typeof(Newznab.Newznab).Name)
|
||||
{
|
||||
var indexer = GetInstance(definition);
|
||||
_newznabTestService.Test(indexer);
|
||||
}
|
||||
|
||||
return base.Create(definition);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,12 +54,12 @@ namespace NzbDrone.Core.ThingiProvider
|
|||
return _providerRepository.Get(id);
|
||||
}
|
||||
|
||||
public TProviderDefinition Create(TProviderDefinition provider)
|
||||
public virtual TProviderDefinition Create(TProviderDefinition definition)
|
||||
{
|
||||
return _providerRepository.Insert(provider);
|
||||
return _providerRepository.Insert(definition);
|
||||
}
|
||||
|
||||
public void Update(TProviderDefinition definition)
|
||||
public virtual void Update(TProviderDefinition definition)
|
||||
{
|
||||
_providerRepository.Update(definition);
|
||||
}
|
||||
|
@ -69,11 +69,9 @@ namespace NzbDrone.Core.ThingiProvider
|
|||
_providerRepository.Delete(id);
|
||||
}
|
||||
|
||||
private TProvider GetInstance(TProviderDefinition definition)
|
||||
protected TProvider GetInstance(TProviderDefinition definition)
|
||||
{
|
||||
var type = GetImplementation(definition);
|
||||
|
||||
//TODO: This doesn't work for things that have non-parameterless constructors
|
||||
var instance = (TProvider)_container.Resolve(type);
|
||||
instance.Definition = definition;
|
||||
return instance;
|
||||
|
|
Loading…
Reference in New Issue