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:
@@ -161,7 +161,7 @@ namespace Jackett.Indexers
|
||||
IsConfigured = false;
|
||||
}
|
||||
|
||||
protected virtual void SaveConfig()
|
||||
public virtual void SaveConfig()
|
||||
{
|
||||
indexerService.SaveConfig(this as IIndexer, configData.ToJson(protectionService, forDisplay: false));
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ namespace Jackett.Indexers
|
||||
|
||||
// Called on startup when initializing indexers from saved configuration
|
||||
void LoadFromSavedConfiguration(JToken jsonConfig);
|
||||
void SaveConfig();
|
||||
|
||||
Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query);
|
||||
|
||||
|
@@ -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