mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-04-24 22:00:49 +02:00
Sync Indexers on app start, go to http if not sync'd yet
This commit is contained in:
parent
17608cf915
commit
bc1e397ce3
1 changed files with 12 additions and 2 deletions
|
|
@ -8,7 +8,9 @@
|
|||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Indexers.Cardigann;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.NamingConventions;
|
||||
|
||||
|
|
@ -21,7 +23,7 @@ public interface IIndexerDefinitionUpdateService
|
|||
List<string> GetBlocklist();
|
||||
}
|
||||
|
||||
public class IndexerDefinitionUpdateService : IIndexerDefinitionUpdateService, IExecute<IndexerDefinitionUpdateCommand>
|
||||
public class IndexerDefinitionUpdateService : IIndexerDefinitionUpdateService, IExecute<IndexerDefinitionUpdateCommand>, IHandle<ApplicationStartedEvent>
|
||||
{
|
||||
/* Update Service will fall back if version # does not exist for an indexer per Ta */
|
||||
|
||||
|
|
@ -199,8 +201,10 @@ private CardigannDefinition GetUncachedDefinition(string fileKey)
|
|||
}
|
||||
}
|
||||
|
||||
var dbDefs = _versionService.All();
|
||||
|
||||
//Check to ensure it's in versioned defs before we go to web
|
||||
if (!_versionService.All().Any(x => x.File == fileKey))
|
||||
if (dbDefs.Count > 0 && dbDefs.Any(x => x.File == fileKey))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fileKey));
|
||||
}
|
||||
|
|
@ -256,6 +260,12 @@ private CardigannDefinition CleanIndexerDefinition(CardigannDefinition definitio
|
|||
return definition;
|
||||
}
|
||||
|
||||
public void Handle(ApplicationStartedEvent message)
|
||||
{
|
||||
// Sync indexers on app start
|
||||
UpdateLocalDefinitions();
|
||||
}
|
||||
|
||||
public void Execute(IndexerDefinitionUpdateCommand message)
|
||||
{
|
||||
UpdateLocalDefinitions();
|
||||
|
|
|
|||
Loading…
Reference in a new issue