mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Automatically load the backup config if the primary one is corrupted
This commit is contained in:
@@ -55,7 +55,27 @@ namespace Jackett.Services
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Failed loading configuration for {0}, you must reconfigure this indexer", idx.DisplayName);
|
||||
logger.Error(ex, "Failed loading configuration for {0}, trying backup", idx.DisplayName);
|
||||
var configFilePathBak = configFilePath + ".bak";
|
||||
if (File.Exists(configFilePathBak))
|
||||
{
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
catch (Exception exbak)
|
||||
{
|
||||
logger.Error(exbak, "Failed loading backup configuration for {0}, you must reconfigure this indexer", idx.DisplayName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error(ex, "Failed loading backup configuration for {0} (no backup available), you must reconfigure this indexer", idx.DisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user