1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02:00

Fixed: Catch InvalidDataException during initial config to prevent boot loop

(cherry picked from commit 9862584611f29ac3f16e0c6ef0afb183ff3f0588)
This commit is contained in:
Qstick 2023-01-21 12:54:37 -06:00 committed by Mark McDowall
parent 77efc4cc40
commit 3a6c078b30

View File

@ -198,10 +198,19 @@ public static ApplicationModes GetApplicationMode(IStartupContext startupContext
private static IConfiguration GetConfiguration(StartupContext context)
{
var appFolder = new AppFolderInfo(context);
return new ConfigurationBuilder()
.AddXmlFile(appFolder.GetConfigPath(), optional: true, reloadOnChange: false)
.AddInMemoryCollection(new List<KeyValuePair<string, string>> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) })
.Build();
var configPath = appFolder.GetConfigPath();
try
{
return new ConfigurationBuilder()
.AddXmlFile(configPath, optional: true, reloadOnChange: false)
.AddInMemoryCollection(new List<KeyValuePair<string, string>> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) })
.Build();
}
catch (InvalidDataException ex)
{
throw new InvalidConfigFileException($"{configPath} is corrupt or invalid. Please delete the config file and Sonarr will recreate it.", ex);
}
}
private static string BuildUrl(string scheme, string bindAddress, int port)