Fixed: Fallback to saved capabilities when syncing failed indexers

pull/2188/head
Bogdan 3 months ago
parent 6549f799f6
commit ac76646a20

@ -11,6 +11,8 @@ namespace NzbDrone.Core.Applications
public abstract class ApplicationBase<TSettings> : IApplication
where TSettings : IProviderConfig, new()
{
private readonly IIndexerFactory _indexerFactory;
protected readonly IAppIndexerMapService _appIndexerMapService;
protected readonly Logger _logger;
@ -27,9 +29,10 @@ namespace NzbDrone.Core.Applications
protected TSettings Settings => (TSettings)Definition.Settings;
public ApplicationBase(IAppIndexerMapService appIndexerMapService, Logger logger)
public ApplicationBase(IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
{
_appIndexerMapService = appIndexerMapService;
_indexerFactory = indexerFactory;
_logger = logger;
}
@ -62,5 +65,17 @@ namespace NzbDrone.Core.Applications
{
return null;
}
protected IndexerCapabilities GetIndexerCapabilities(IndexerDefinition indexer)
{
try
{
return _indexerFactory.GetInstance(indexer).GetCapabilities();
}
catch (Exception)
{
return indexer.Capabilities;
}
}
}
}

@ -15,14 +15,12 @@ namespace NzbDrone.Core.Applications.LazyLibrarian
private readonly ILazyLibrarianV1Proxy _lazyLibrarianV1Proxy;
private readonly IConfigFileProvider _configFileProvider;
private readonly IIndexerFactory _indexerFactory;
public LazyLibrarian(ILazyLibrarianV1Proxy lazyLibrarianV1Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
: base(appIndexerMapService, logger)
: base(appIndexerMapService, indexerFactory, logger)
{
_lazyLibrarianV1Proxy = lazyLibrarianV1Proxy;
_configFileProvider = configFileProvider;
_indexerFactory = indexerFactory;
}
public override ValidationResult Test()
@ -67,7 +65,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian
public override void AddIndexer(IndexerDefinition indexer)
{
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty())
{
@ -111,7 +109,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian
{
_logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id);
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id);
var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);
var indexerProps = indexerMapping.RemoteIndexerName.Split(",");

@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Lidarr
private readonly ILidarrV1Proxy _lidarrV1Proxy;
private readonly ICached<List<LidarrIndexer>> _schemaCache;
private readonly IConfigFileProvider _configFileProvider;
private readonly IIndexerFactory _indexerFactory;
public Lidarr(ICacheManager cacheManager, ILidarrV1Proxy lidarrV1Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
: base(appIndexerMapService, logger)
: base(appIndexerMapService, indexerFactory, logger)
{
_schemaCache = cacheManager.GetCache<List<LidarrIndexer>>(GetType());
_lidarrV1Proxy = lidarrV1Proxy;
_configFileProvider = configFileProvider;
_indexerFactory = indexerFactory;
}
public override ValidationResult Test()
@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Lidarr
public override void AddIndexer(IndexerDefinition indexer)
{
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty())
{
@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Lidarr
{
_logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id);
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id);
var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);

@ -15,14 +15,12 @@ namespace NzbDrone.Core.Applications.Mylar
private readonly IMylarV3Proxy _mylarV3Proxy;
private readonly IConfigFileProvider _configFileProvider;
private readonly IIndexerFactory _indexerFactory;
public Mylar(IMylarV3Proxy mylarV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
: base(appIndexerMapService, logger)
: base(appIndexerMapService, indexerFactory, logger)
{
_mylarV3Proxy = mylarV3Proxy;
_configFileProvider = configFileProvider;
_indexerFactory = indexerFactory;
}
public override ValidationResult Test()
@ -67,7 +65,7 @@ namespace NzbDrone.Core.Applications.Mylar
public override void AddIndexer(IndexerDefinition indexer)
{
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty())
{
@ -111,7 +109,7 @@ namespace NzbDrone.Core.Applications.Mylar
{
_logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id);
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id);
var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);
var indexerProps = indexerMapping.RemoteIndexerName.Split(",");

@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Radarr
private readonly IRadarrV3Proxy _radarrV3Proxy;
private readonly ICached<List<RadarrIndexer>> _schemaCache;
private readonly IConfigFileProvider _configFileProvider;
private readonly IIndexerFactory _indexerFactory;
public Radarr(ICacheManager cacheManager, IRadarrV3Proxy radarrV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
: base(appIndexerMapService, logger)
: base(appIndexerMapService, indexerFactory, logger)
{
_schemaCache = cacheManager.GetCache<List<RadarrIndexer>>(GetType());
_radarrV3Proxy = radarrV3Proxy;
_configFileProvider = configFileProvider;
_indexerFactory = indexerFactory;
}
public override ValidationResult Test()
@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Radarr
public override void AddIndexer(IndexerDefinition indexer)
{
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty())
{
@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Radarr
{
_logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id);
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id);
var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);

@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Readarr
private readonly ICached<List<ReadarrIndexer>> _schemaCache;
private readonly IReadarrV1Proxy _readarrV1Proxy;
private readonly IConfigFileProvider _configFileProvider;
private readonly IIndexerFactory _indexerFactory;
public Readarr(ICacheManager cacheManager, IReadarrV1Proxy readarrV1Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
: base(appIndexerMapService, logger)
: base(appIndexerMapService, indexerFactory, logger)
{
_schemaCache = cacheManager.GetCache<List<ReadarrIndexer>>(GetType());
_readarrV1Proxy = readarrV1Proxy;
_configFileProvider = configFileProvider;
_indexerFactory = indexerFactory;
}
public override ValidationResult Test()
@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Readarr
public override void AddIndexer(IndexerDefinition indexer)
{
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty())
{
@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Readarr
{
_logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id);
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id);
var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);

@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Sonarr
private readonly ICached<List<SonarrIndexer>> _schemaCache;
private readonly ISonarrV3Proxy _sonarrV3Proxy;
private readonly IConfigFileProvider _configFileProvider;
private readonly IIndexerFactory _indexerFactory;
public Sonarr(ICacheManager cacheManager, ISonarrV3Proxy sonarrV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
: base(appIndexerMapService, logger)
: base(appIndexerMapService, indexerFactory, logger)
{
_schemaCache = cacheManager.GetCache<List<SonarrIndexer>>(GetType());
_sonarrV3Proxy = sonarrV3Proxy;
_configFileProvider = configFileProvider;
_indexerFactory = indexerFactory;
}
public override ValidationResult Test()
@ -124,7 +122,7 @@ namespace NzbDrone.Core.Applications.Sonarr
public override void AddIndexer(IndexerDefinition indexer)
{
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty() &&
indexerCapabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray()).Empty())
@ -168,7 +166,7 @@ namespace NzbDrone.Core.Applications.Sonarr
{
_logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id);
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id);
var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);

@ -21,15 +21,13 @@ namespace NzbDrone.Core.Applications.Whisparr
private readonly IWhisparrV3Proxy _whisparrV3Proxy;
private readonly ICached<List<WhisparrIndexer>> _schemaCache;
private readonly IConfigFileProvider _configFileProvider;
private readonly IIndexerFactory _indexerFactory;
public Whisparr(ICacheManager cacheManager, IWhisparrV3Proxy whisparrV3Proxy, IConfigFileProvider configFileProvider, IAppIndexerMapService appIndexerMapService, IIndexerFactory indexerFactory, Logger logger)
: base(appIndexerMapService, logger)
: base(appIndexerMapService, indexerFactory, logger)
{
_schemaCache = cacheManager.GetCache<List<WhisparrIndexer>>(GetType());
_whisparrV3Proxy = whisparrV3Proxy;
_configFileProvider = configFileProvider;
_indexerFactory = indexerFactory;
}
public override ValidationResult Test()
@ -120,7 +118,7 @@ namespace NzbDrone.Core.Applications.Whisparr
public override void AddIndexer(IndexerDefinition indexer)
{
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
if (indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Empty())
{
@ -163,7 +161,7 @@ namespace NzbDrone.Core.Applications.Whisparr
{
_logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id);
var indexerCapabilities = _indexerFactory.GetInstance(indexer).GetCapabilities();
var indexerCapabilities = GetIndexerCapabilities(indexer);
var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id);
var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id);

Loading…
Cancel
Save