1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-24 00:33:05 +00:00

Fixed: XML clean extra spaces from config file settings when saving/retrieving

This commit is contained in:
Mark McDowall 2014-01-07 17:37:51 -08:00
parent e00b216eef
commit a422587ed5

View file

@ -197,7 +197,7 @@ public string GetValue(string key, object defaultValue, bool persist = true)
var valueHolder = parentContainer.Descendants(key).ToList();
if (valueHolder.Count() == 1)
return valueHolder.First().Value;
return valueHolder.First().Value.Trim();
//Save the value
if (persist)
@ -214,6 +214,7 @@ public void SetValue(string key, object value)
{
EnsureDefaultConfigFile();
var valueString = value.ToString().Trim();
var xDoc = LoadConfigFile();
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
@ -223,15 +224,15 @@ public void SetValue(string key, object value)
if (keyHolder.Count() != 1)
{
parentContainer.Add(new XElement(key, value));
parentContainer.Add(new XElement(key, valueString));
}
else
{
parentContainer.Descendants(key).Single().Value = value.ToString();
parentContainer.Descendants(key).Single().Value = valueString;
}
_cache.Set(key, value.ToString());
_cache.Set(key, valueString);
xDoc.Save(_configFile);
}