Pull list from Index server instead of local

pull/6/head
Qstick 4 years ago
parent a4703cabda
commit 824263074a

@ -47,23 +47,18 @@ namespace NzbDrone.Core.IndexerVersions
public List<CardigannMetaDefinition> All() public List<CardigannMetaDefinition> All()
{ {
var request = new HttpRequest($"https://indexers.prowlarr.com/master/{DEFINITION_VERSION}");
var response = _httpClient.Get<List<CardigannMetaDefinition>>(request);
var remoteDefs = response.Resource.ToDictionary(x => x.File);
var startupFolder = _appFolderInfo.StartUpFolder;
var prefix = Path.Combine(startupFolder, "Definitions");
var directoryInfos = new List<DirectoryInfo> { new DirectoryInfo(prefix) };
var existingDirectories = directoryInfos.Where(d => d.Exists);
var files = existingDirectories.SelectMany(d => d.GetFiles("*.yml"));
var indexerList = new List<CardigannMetaDefinition>(); var indexerList = new List<CardigannMetaDefinition>();
foreach (var file in files) try
{
var request = new HttpRequest($"https://indexers.prowlarr.com/master/{DEFINITION_VERSION}");
var response = _httpClient.Get<List<CardigannMetaDefinition>>(request);
indexerList = response.Resource;
indexerList.AddRange(response.Resource);
}
catch
{ {
indexerList.AddIfNotNull(remoteDefs[Path.GetFileNameWithoutExtension(file.Name)]); _logger.Error("Failed to Connect to Indexer Definition Server for Indexer listing");
} }
return indexerList; return indexerList;

Loading…
Cancel
Save