mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: XML clean extra spaces from config file settings when saving/retrieving
This commit is contained in:
parent
e00b216eef
commit
a422587ed5
@ -197,7 +197,7 @@ public string GetValue(string key, object defaultValue, bool persist = true)
|
|||||||
var valueHolder = parentContainer.Descendants(key).ToList();
|
var valueHolder = parentContainer.Descendants(key).ToList();
|
||||||
|
|
||||||
if (valueHolder.Count() == 1)
|
if (valueHolder.Count() == 1)
|
||||||
return valueHolder.First().Value;
|
return valueHolder.First().Value.Trim();
|
||||||
|
|
||||||
//Save the value
|
//Save the value
|
||||||
if (persist)
|
if (persist)
|
||||||
@ -214,6 +214,7 @@ public void SetValue(string key, object value)
|
|||||||
{
|
{
|
||||||
EnsureDefaultConfigFile();
|
EnsureDefaultConfigFile();
|
||||||
|
|
||||||
|
var valueString = value.ToString().Trim();
|
||||||
var xDoc = LoadConfigFile();
|
var xDoc = LoadConfigFile();
|
||||||
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
||||||
|
|
||||||
@ -223,15 +224,15 @@ public void SetValue(string key, object value)
|
|||||||
|
|
||||||
if (keyHolder.Count() != 1)
|
if (keyHolder.Count() != 1)
|
||||||
{
|
{
|
||||||
parentContainer.Add(new XElement(key, value));
|
parentContainer.Add(new XElement(key, valueString));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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);
|
xDoc.Save(_configFile);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user