Fixed: Improve error messaging if config file isn't formatted correctly

pull/3516/head
servarr[bot] 10 months ago committed by GitHub
parent c362e8c467
commit 5b1b2a2d67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -404,14 +404,22 @@ namespace NzbDrone.Core.Configuration
throw new InvalidConfigFileException($"{_configFile} is corrupt. Please delete the config file and Readarr will recreate it."); throw new InvalidConfigFileException($"{_configFile} is corrupt. Please delete the config file and Readarr will recreate it.");
} }
return XDocument.Parse(_diskProvider.ReadAllText(_configFile)); var xDoc = XDocument.Parse(_diskProvider.ReadAllText(_configFile));
} var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).ToList();
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); if (config.Count != 1)
xDoc.Add(new XElement(CONFIG_ELEMENT_NAME)); {
throw new InvalidConfigFileException($"{_configFile} is invalid. Please delete the config file and Readarr will recreate it.");
}
return xDoc; return xDoc;
} }
var newXDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
newXDoc.Add(new XElement(CONFIG_ELEMENT_NAME));
return newXDoc;
}
} }
catch (XmlException ex) catch (XmlException ex)
{ {

Loading…
Cancel
Save