mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 04:59:35 -07:00
Fixed: Improve error messaging if config file isn't formatted correctly
(cherry picked from commit 52b72925f9d42c896144dde3099dc19c397327b0)
This commit is contained in:
parent
7d46360c34
commit
448d29f135
1 changed files with 12 additions and 4 deletions
|
@ -403,13 +403,21 @@ namespace NzbDrone.Core.Configuration
|
||||||
throw new InvalidConfigFileException($"{_configFile} is corrupt. Please delete the config file and Lidarr will recreate it.");
|
throw new InvalidConfigFileException($"{_configFile} is corrupt. Please delete the config file and Lidarr 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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return xDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
var xDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
var newXDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
|
||||||
xDoc.Add(new XElement(CONFIG_ELEMENT_NAME));
|
newXDoc.Add(new XElement(CONFIG_ELEMENT_NAME));
|
||||||
|
|
||||||
return xDoc;
|
return newXDoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (XmlException ex)
|
catch (XmlException ex)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue