From fb25e5d577565ec03e342fa63f7869ed66382a94 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 9a0857e044..ad6c265f8e 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -219,11 +219,20 @@ 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> { 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 Radarr will recreate it.", ex); + } } private static string BuildUrl(string scheme, string bindAddress, int port)