mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-22 07:43:01 +00:00
Fixed: Improve error messaging if config file isn't formatted correctly
Closes #6860
This commit is contained in:
parent
378fedcd9d
commit
52b72925f9
1 changed files with 12 additions and 4 deletions
|
@ -419,14 +419,22 @@ namespace NzbDrone.Core.Configuration
|
||||||
throw new InvalidConfigFileException($"{_configFile} is corrupt. Please delete the config file and Sonarr will recreate it.");
|
throw new InvalidConfigFileException($"{_configFile} is corrupt. Please delete the config file and Sonarr will recreate it.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return XDocument.Parse(_diskProvider.ReadAllText(_configFile));
|
var xDoc = XDocument.Parse(_diskProvider.ReadAllText(_configFile));
|
||||||
|
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).ToList();
|
||||||
|
|
||||||
|
if (config.Count != 1)
|
||||||
|
{
|
||||||
|
throw new InvalidConfigFileException($"{_configFile} is invalid. Please delete the config file and Sonarr will recreate it.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
|
||||||
xDoc.Add(new XElement(CONFIG_ELEMENT_NAME));
|
|
||||||
|
|
||||||
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…
Reference in a new issue