mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Load definitions from multiple directories
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Jackett.Services
|
||||
T GetConfig<T>();
|
||||
void SaveConfig<T>(T config);
|
||||
string ApplicationFolder();
|
||||
string GetCardigannDefinitionsFolder();
|
||||
List<string> GetCardigannDefinitionsFolders();
|
||||
void CreateOrMigrateSettings();
|
||||
void PerformMigration();
|
||||
}
|
||||
@@ -198,8 +198,21 @@ namespace Jackett.Services
|
||||
return dir;
|
||||
}
|
||||
|
||||
public string GetCardigannDefinitionsFolder()
|
||||
public List<string> GetCardigannDefinitionsFolders()
|
||||
{
|
||||
List<string> dirs = new List<string>();
|
||||
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
dirs.Add(Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config/cardigann/definitions/"));
|
||||
dirs.Add("/etc/xdg/cardigan/definitions/");
|
||||
}
|
||||
else
|
||||
{
|
||||
dirs.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "cardigann\\definitions\\"));
|
||||
dirs.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cardigann\\definitions\\"));
|
||||
}
|
||||
|
||||
// If we are debugging we can use the non copied definitions.
|
||||
string dir = Path.Combine(ApplicationFolder(), "Definitions"); ;
|
||||
|
||||
@@ -211,7 +224,8 @@ namespace Jackett.Services
|
||||
dir = sourcePath;
|
||||
}
|
||||
#endif
|
||||
return dir;
|
||||
dirs.Add(dir);
|
||||
return dirs;
|
||||
}
|
||||
|
||||
public string GetVersion()
|
||||
|
@@ -76,10 +76,14 @@ namespace Jackett.Services
|
||||
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
return;
|
||||
|
||||
DirectoryInfo d = new DirectoryInfo(path);
|
||||
|
||||
foreach (var file in d.GetFiles("*.yml"))
|
||||
{
|
||||
logger.Info("Loading Cardigann definition " + file.FullName);
|
||||
string DefinitionString = File.ReadAllText(file.FullName);
|
||||
CardigannIndexer idx = new CardigannIndexer(this, container.Resolve<IWebClient>(), logger, container.Resolve<IProtectionService>(), DefinitionString);
|
||||
if (indexers.ContainsKey(idx.ID))
|
||||
|
@@ -150,7 +150,10 @@ namespace Jackett.Services
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
|
||||
// Load indexers
|
||||
indexerService.InitIndexers();
|
||||
indexerService.InitCardigannIndexers(configService.GetCardigannDefinitionsFolder());
|
||||
foreach(string dir in configService.GetCardigannDefinitionsFolders())
|
||||
{
|
||||
indexerService.InitCardigannIndexers(dir);
|
||||
}
|
||||
client.Init();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user