mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Fixed: Error messages when config file is empty or contains invalid characters
Closes #1104
This commit is contained in:
parent
4f5d79b189
commit
ea0982ecae
3 changed files with 45 additions and 3 deletions
|
@ -348,6 +348,18 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
if (_diskProvider.FileExists(_configFile))
|
||||
{
|
||||
var contents = _diskProvider.ReadAllText(_configFile);
|
||||
|
||||
if (contents.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new InvalidConfigFileException($"{_configFile} is empty. Please delete the config file and Sonarr will recreate it.");
|
||||
}
|
||||
|
||||
if (contents.All(char.IsControl))
|
||||
{
|
||||
throw new InvalidConfigFileException($"{_configFile} is corrupt. Please delete the config file and Sonarr will recreate it.");
|
||||
}
|
||||
|
||||
return XDocument.Parse(_diskProvider.ReadAllText(_configFile));
|
||||
}
|
||||
|
||||
|
@ -360,7 +372,7 @@ namespace NzbDrone.Core.Configuration
|
|||
|
||||
catch (XmlException ex)
|
||||
{
|
||||
throw new InvalidConfigFileException(_configFile + " is invalid, please see the http://wiki.sonarr.tv for steps to resolve this issue.", ex);
|
||||
throw new InvalidConfigFileException($"{_configFile} is corrupt is invalid. Please delete the config file and Sonarr will recreate it.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue