mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
@@ -30,6 +30,15 @@ namespace Jackett.Common.Services
|
||||
private readonly Dictionary<string, IIndexer> indexers = new Dictionary<string, IIndexer>();
|
||||
private AggregateIndexer aggregateIndexer;
|
||||
|
||||
// this map is used to maintain backward compatibility when renaming the id of an indexer
|
||||
// (the id is used in the torznab/download/search urls and in the indexer configuration file)
|
||||
// if the indexer is removed, remove it from this list too
|
||||
// use: {"<old id>", "<new id>"}
|
||||
private readonly Dictionary<string, string> renamedIndexers = new Dictionary<string, string>
|
||||
{
|
||||
{"nostalgic", "vhstapes"}
|
||||
};
|
||||
|
||||
public IndexerManagerService(IIndexerConfigurationService config, IProtectionService protectionService, WebClient webClient, Logger l, ICacheService cache, IProcessService processService, IConfigurationService globalConfigService, ServerConfig serverConfig)
|
||||
{
|
||||
configService = config;
|
||||
@@ -44,11 +53,29 @@ namespace Jackett.Common.Services
|
||||
|
||||
public void InitIndexers(IEnumerable<string> path)
|
||||
{
|
||||
MigrateRenamedIndexers();
|
||||
InitIndexers();
|
||||
InitCardigannIndexers(path);
|
||||
InitAggregateIndexer();
|
||||
}
|
||||
|
||||
private void MigrateRenamedIndexers()
|
||||
{
|
||||
foreach (var oldId in renamedIndexers.Keys)
|
||||
{
|
||||
var oldPath = configService.GetIndexerConfigFilePath(oldId);
|
||||
if (File.Exists(oldPath))
|
||||
{
|
||||
// if the old configuration exists, we rename it to be used by the renamed indexer
|
||||
var newPath = configService.GetIndexerConfigFilePath(renamedIndexers[oldId]);
|
||||
File.Move(oldPath, newPath);
|
||||
if (File.Exists(oldPath + ".bak"))
|
||||
File.Move(oldPath + ".bak", newPath + ".bak");
|
||||
logger.Info($"Configuration renamed: {oldPath} => {newPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitIndexers()
|
||||
{
|
||||
logger.Info("Using HTTP Client: " + webClient.GetType().Name);
|
||||
@@ -179,19 +206,24 @@ namespace Jackett.Common.Services
|
||||
|
||||
public IIndexer GetIndexer(string name)
|
||||
{
|
||||
if (indexers.ContainsKey(name))
|
||||
// old id of renamed indexer is used to maintain backward compatibility
|
||||
// both, the old id and the new one can be used until we remove it from renamedIndexers
|
||||
var realName = name;
|
||||
if (renamedIndexers.ContainsKey(name))
|
||||
{
|
||||
return indexers[name];
|
||||
realName = renamedIndexers[name];
|
||||
logger.Warn($"Indexer {name} has been renamed to {realName}. Please, update the URL of the feeds. " +
|
||||
"This may stop working in the future.");
|
||||
}
|
||||
else if (name == "all")
|
||||
{
|
||||
|
||||
if (indexers.ContainsKey(realName))
|
||||
return indexers[realName];
|
||||
|
||||
if (realName == "all")
|
||||
return aggregateIndexer;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error("Request for unknown indexer: " + name);
|
||||
throw new Exception("Unknown indexer: " + name);
|
||||
}
|
||||
|
||||
logger.Error("Request for unknown indexer: " + realName);
|
||||
throw new Exception("Unknown indexer: " + realName);
|
||||
}
|
||||
|
||||
public IWebIndexer GetWebIndexer(string name)
|
||||
|
Reference in New Issue
Block a user