Fixing a null exception when searching AnimeTosho

AnimeTosho failed to populate the Origin field of the results when
searching thereby creating an issue upon creating the proxy link. This
was mainly because an IEnumerable can contain a deferred LINQ query as
well (e.g. in the case of AnimeTosho a Select) that will re-execute
every single time. So when iterating over IEnumerables we cannot really
pose any assumption on what we are dealing with, so either explicitly
force an execution (e.g. via ToList), or use LINQ queries as well. Since
the second is probably more performant, let's stick with that.
This commit is contained in:
chibidev 2017-07-29 13:20:10 +02:00
parent 6fbc4b6904
commit 057df28d1b
1 changed files with 4 additions and 3 deletions

View File

@ -218,10 +218,11 @@ namespace Jackett.Indexers
{
var results = await PerformQuery(query);
results = FilterResults(query, results);
foreach (var result in results)
results = results.Select(r =>
{
result.Origin = this;
}
r.Origin = this;
return r;
});
return results;
}