Sync Indexers on app start, go to http if not sync'd yet

pull/818/head v0.2.0.1448
Qstick 3 years ago
parent 17608cf915
commit bc1e397ce3

@ -8,7 +8,9 @@ using NzbDrone.Common.Disk;
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 @@ namespace NzbDrone.Core.IndexerVersions
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 @@ namespace NzbDrone.Core.IndexerVersions
}
}
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 @@ namespace NzbDrone.Core.IndexerVersions
return definition;
}
public void Handle(ApplicationStartedEvent message)
{
// Sync indexers on app start
UpdateLocalDefinitions();
}
public void Execute(IndexerDefinitionUpdateCommand message)
{
UpdateLocalDefinitions();

Loading…
Cancel
Save