Fixed: Cardigann nullref from App add on Indexer Add

pull/25/head
Qstick 4 years ago
parent bf0c095d55
commit 4c279652c0

@ -49,14 +49,7 @@ namespace NzbDrone.Core.Indexers
{
if (definition.Implementation == typeof(Cardigann.Cardigann).Name)
{
var settings = (CardigannSettings)definition.Settings;
var defFile = _definitionService.GetDefinition(settings.DefinitionFile);
definition.ExtraFields = defFile.Settings;
definition.BaseUrl = defFile.Links.First();
definition.Privacy = defFile.Type == "private" ? IndexerPrivacy.Private : IndexerPrivacy.Public;
definition.Capabilities = new IndexerCapabilities();
definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes);
MapCardigannCategories(definition, defFile);
MapCardigannDefinition(definition);
}
}
@ -69,14 +62,7 @@ namespace NzbDrone.Core.Indexers
if (definition.Implementation == typeof(Cardigann.Cardigann).Name)
{
var settings = (CardigannSettings)definition.Settings;
var defFile = _definitionService.GetDefinition(settings.DefinitionFile);
definition.ExtraFields = defFile.Settings;
definition.BaseUrl = defFile.Links.First();
definition.Privacy = defFile.Type == "private" ? IndexerPrivacy.Private : IndexerPrivacy.Public;
definition.Capabilities = new IndexerCapabilities();
definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes);
MapCardigannCategories(definition, defFile);
MapCardigannDefinition(definition);
}
return definition;
@ -87,6 +73,18 @@ namespace NzbDrone.Core.Indexers
return base.Active().Where(c => c.Enable).ToList();
}
private void MapCardigannDefinition(IndexerDefinition definition)
{
var settings = (CardigannSettings)definition.Settings;
var defFile = _definitionService.GetDefinition(settings.DefinitionFile);
definition.ExtraFields = defFile.Settings;
definition.BaseUrl = defFile.Links.First();
definition.Privacy = defFile.Type == "private" ? IndexerPrivacy.Private : IndexerPrivacy.Public;
definition.Capabilities = new IndexerCapabilities();
definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes);
MapCardigannCategories(definition, defFile);
}
private void MapCardigannCategories(IndexerDefinition def, CardigannDefinition defFile)
{
if (defFile.Caps.Categories != null)
@ -232,6 +230,11 @@ namespace NzbDrone.Core.Indexers
settings.Categories = _newznabCapabilitiesProvider.GetCapabilities(settings)?.Categories.GetTorznabCategoryList() ?? null;
}
if (definition.Implementation == typeof(Cardigann.Cardigann).Name)
{
MapCardigannDefinition(definition);
}
return base.Create(definition);
}
@ -245,6 +248,11 @@ namespace NzbDrone.Core.Indexers
settings.Categories = _newznabCapabilitiesProvider.GetCapabilities(settings)?.Categories.GetTorznabCategoryList() ?? null;
}
if (definition.Implementation == typeof(Cardigann.Cardigann).Name)
{
MapCardigannDefinition(definition);
}
base.Update(definition);
}
}

Loading…
Cancel
Save