mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
@@ -33,7 +33,7 @@ namespace Jackett.Common.Services
|
||||
|
||||
public void Delete(IIndexer indexer)
|
||||
{
|
||||
var configFilePath = GetIndexerConfigFilePath(indexer);
|
||||
var configFilePath = GetIndexerConfigFilePath(indexer.Id);
|
||||
File.Delete(configFilePath);
|
||||
var configFilePathBak = configFilePath + ".bak";
|
||||
if (File.Exists(configFilePathBak))
|
||||
@@ -42,20 +42,20 @@ namespace Jackett.Common.Services
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(IIndexer idx)
|
||||
public void Load(IIndexer indexer)
|
||||
{
|
||||
var configFilePath = GetIndexerConfigFilePath(idx);
|
||||
var configFilePath = GetIndexerConfigFilePath(indexer.Id);
|
||||
if (File.Exists(configFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileStr = File.ReadAllText(configFilePath);
|
||||
var jsonString = JToken.Parse(fileStr);
|
||||
idx.LoadFromSavedConfiguration(jsonString);
|
||||
indexer.LoadFromSavedConfiguration(jsonString);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Failed loading configuration for {0}, trying backup", idx.DisplayName);
|
||||
logger.Error(ex, "Failed loading configuration for {0}, trying backup", indexer.DisplayName);
|
||||
var configFilePathBak = configFilePath + ".bak";
|
||||
if (File.Exists(configFilePathBak))
|
||||
{
|
||||
@@ -63,18 +63,18 @@ namespace Jackett.Common.Services
|
||||
{
|
||||
var fileStrBak = File.ReadAllText(configFilePathBak);
|
||||
var jsonStringBak = JToken.Parse(fileStrBak);
|
||||
idx.LoadFromSavedConfiguration(jsonStringBak);
|
||||
logger.Info("Successfully loaded backup config for {0}", idx.DisplayName);
|
||||
idx.SaveConfig();
|
||||
indexer.LoadFromSavedConfiguration(jsonStringBak);
|
||||
logger.Info("Successfully loaded backup config for {0}", indexer.DisplayName);
|
||||
indexer.SaveConfig();
|
||||
}
|
||||
catch (Exception exbak)
|
||||
{
|
||||
logger.Error(exbak, "Failed loading backup configuration for {0}, you must reconfigure this indexer", idx.DisplayName);
|
||||
logger.Error(exbak, "Failed loading backup configuration for {0}, you must reconfigure this indexer", indexer.DisplayName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error(ex, "Failed loading backup configuration for {0} (no backup available), you must reconfigure this indexer", idx.DisplayName);
|
||||
logger.Error(ex, "Failed loading backup configuration for {0} (no backup available), you must reconfigure this indexer", indexer.DisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace Jackett.Common.Services
|
||||
lock (configWriteLock)
|
||||
{
|
||||
var uID = Guid.NewGuid().ToString("N");
|
||||
var configFilePath = GetIndexerConfigFilePath(indexer);
|
||||
var configFilePath = GetIndexerConfigFilePath(indexer.Id);
|
||||
var configFilePathBak = configFilePath + ".bak";
|
||||
var configFilePathTmp = configFilePath + "." + uID + ".tmp";
|
||||
var content = obj.ToString();
|
||||
@@ -141,7 +141,8 @@ namespace Jackett.Common.Services
|
||||
}
|
||||
}
|
||||
|
||||
private string GetIndexerConfigFilePath(IIndexer indexer) => Path.Combine(configService.GetIndexerConfigDir(), indexer.Id + ".json");
|
||||
public string GetIndexerConfigFilePath(string indexerId)
|
||||
=> Path.Combine(configService.GetIndexerConfigDir(), indexerId + ".json");
|
||||
|
||||
private readonly IConfigurationService configService;
|
||||
private readonly Logger logger;
|
||||
|
Reference in New Issue
Block a user