From 94d7f56743de16fe0bd946035cc3d99f387709fe Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 21 Jan 2023 12:54:37 -0600 Subject: [PATCH] Fixed: Catch InvalidDataException during initial config to prevent boot loop [Common] --- src/NzbDrone.Host/Bootstrap.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index e8699228f..7d289054f 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -211,11 +211,20 @@ namespace NzbDrone.Host private static IConfiguration GetConfiguration(StartupContext context) { var appFolder = new AppFolderInfo(context); - return new ConfigurationBuilder() - .AddXmlFile(appFolder.GetConfigPath(), optional: true, reloadOnChange: false) - .AddInMemoryCollection(new List> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) }) - .AddEnvironmentVariables() - .Build(); + var configPath = appFolder.GetConfigPath(); + + try + { + return new ConfigurationBuilder() + .AddXmlFile(configPath, optional: true, reloadOnChange: false) + .AddInMemoryCollection(new List> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) }) + .AddEnvironmentVariables() + .Build(); + } + catch (InvalidDataException ex) + { + throw new InvalidConfigFileException($"{configPath} is corrupt or invalid. Please delete the config file and Lidarr will recreate it.", ex); + } } private static string BuildUrl(string scheme, string bindAddress, int port)