Fixed: Don't die when definition doesn't exist

Fixes #596
pull/681/head
Qstick 3 years ago
parent 79e3e31028
commit 9dadb35b98

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using FluentValidation.Results; using FluentValidation.Results;
using NLog; using NLog;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Indexers.Cardigann; using NzbDrone.Core.Indexers.Cardigann;
using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.IndexerVersions; using NzbDrone.Core.IndexerVersions;
@ -45,16 +46,27 @@ namespace NzbDrone.Core.Indexers
public override List<IndexerDefinition> All() public override List<IndexerDefinition> All()
{ {
var definitions = base.All(); var definitions = base.All();
var filteredDefinitions = new List<IndexerDefinition>();
foreach (var definition in definitions) foreach (var definition in definitions)
{ {
if (definition.Implementation == typeof(Cardigann.Cardigann).Name) if (definition.Implementation == typeof(Cardigann.Cardigann).Name)
{
try
{ {
MapCardigannDefinition(definition); MapCardigannDefinition(definition);
} }
catch
{
// Skip indexer if we fail in Cardigann mapping
continue;
}
}
filteredDefinitions.Add(definition);
} }
return definitions; return filteredDefinitions;
} }
public override IndexerDefinition Get(int id) public override IndexerDefinition Get(int id)
@ -62,9 +74,16 @@ namespace NzbDrone.Core.Indexers
var definition = base.Get(id); var definition = base.Get(id);
if (definition.Implementation == typeof(Cardigann.Cardigann).Name) if (definition.Implementation == typeof(Cardigann.Cardigann).Name)
{
try
{ {
MapCardigannDefinition(definition); MapCardigannDefinition(definition);
} }
catch
{
throw new ModelNotFoundException(typeof(IndexerDefinition), id);
}
}
return definition; return definition;
} }

Loading…
Cancel
Save