Sort indexers once all are loaded

This commit is contained in:
kaso17 2016-12-05 13:03:30 +01:00
parent c38a2533e1
commit 412df7c6f6
2 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,7 @@ namespace Jackett.Services
void SaveConfig(IIndexer indexer, JToken obj);
void InitIndexers();
void InitCardigannIndexers(string path);
void SortIndexers();
}
public class IndexerManagerService : IIndexerManagerService
@ -202,6 +203,16 @@ namespace Jackett.Services
{
logger.Error(string.Format("Error while moving {0} to {1}: {2}", configFilePathTmp, configFilePath, ex.ToString()));
}
}
}
public void SortIndexers()
{
// Apparently Dictionary are ordered but can't be sorted again
// This will recreate the indexers Dictionary to workaround this limitation
Dictionary<string, IIndexer> newIndexers = new Dictionary<string, IIndexer>();
foreach (var indexer in indexers.OrderBy(_ => _.Value.DisplayName))
newIndexers.Add(indexer.Key, indexer.Value);
indexers = newIndexers;
}
}
}

View File

@ -154,6 +154,7 @@ namespace Jackett.Services
{
indexerService.InitCardigannIndexers(dir);
}
indexerService.SortIndexers();
client.Init();
}