mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Fixing a bunch of issues with the newly added AggregateIndexer (#1324)
This patch improves the general stability of the aggregate. - Result is generated even if some trackers failed to answer or some other issue were encountered - Fixes Jackett/Jackett#1316
This commit is contained in:
@@ -37,9 +37,16 @@ namespace Jackett.Indexers
|
||||
tasks.Add(indexer.PerformQuery(query));
|
||||
|
||||
var t = Task.WhenAll<IEnumerable<ReleaseInfo>>(tasks);
|
||||
t.Wait();
|
||||
try
|
||||
{
|
||||
t.Wait();
|
||||
}
|
||||
catch (AggregateException exception)
|
||||
{
|
||||
logger.Error(exception, "Error during request from Aggregate");
|
||||
}
|
||||
|
||||
IEnumerable<ReleaseInfo> result = t.Result.SelectMany(x => x).OrderByDescending(r => r.PublishDate);
|
||||
IEnumerable<ReleaseInfo> result = tasks.Where(x => x.Status == TaskStatus.RanToCompletion).SelectMany(x => x.Result).OrderByDescending(r => r.PublishDate);
|
||||
// Limiting the response size might be interesting for use-cases where there are
|
||||
// tons of trackers configured in Jackett. For now just use the limit param if
|
||||
// someone wants to do that.
|
||||
@@ -47,5 +54,33 @@ namespace Jackett.Indexers
|
||||
result = result.Take(query.Limit);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override Uri UncleanLink(Uri link)
|
||||
{
|
||||
var indexer = GetOriginalIndexerForLink(link);
|
||||
if (indexer != null)
|
||||
return indexer.UncleanLink(link);
|
||||
|
||||
return base.UncleanLink(link);
|
||||
}
|
||||
|
||||
public Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var indexer = GetOriginalIndexerForLink(link);
|
||||
if (indexer != null)
|
||||
return indexer.Download(link);
|
||||
|
||||
return base.Download(link);
|
||||
}
|
||||
|
||||
private IIndexer GetOriginalIndexerForLink(Uri link)
|
||||
{
|
||||
var prefix = string.Format("{0}://{1}", link.Scheme, link.Host);
|
||||
var validIndexers = Indexers.Where(i => i.IsConfigured && i.SiteLink.StartsWith(prefix));
|
||||
if (validIndexers.Count() > 0)
|
||||
return validIndexers.First();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -105,7 +105,7 @@ namespace Jackett.Indexers
|
||||
return releases;
|
||||
}
|
||||
|
||||
public Uri UncleanLink(Uri link)
|
||||
public virtual Uri UncleanLink(Uri link)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(downloadUrlBase))
|
||||
{
|
||||
|
@@ -132,7 +132,7 @@ namespace Jackett.Services
|
||||
{
|
||||
logger.Info("Adding aggregate indexer");
|
||||
AggregateIndexer aggregateIndexer = new AggregateIndexer(this, container.Resolve<IWebClient>(), logger, container.Resolve<IProtectionService>());
|
||||
aggregateIndexer.SetIndexers(indexers.Values);
|
||||
aggregateIndexer.SetIndexers(indexers.Where(p => p.Value.IsConfigured).Select(p => p.Value));
|
||||
|
||||
this.aggregateIndexer = aggregateIndexer;
|
||||
}
|
||||
|
Reference in New Issue
Block a user