mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 17:27:59 +00:00
Added SaveValues to ConfigService
This commit is contained in:
parent
9bb383e2b8
commit
3dcf99753e
3 changed files with 20 additions and 0 deletions
|
@ -32,6 +32,8 @@ private Response GetAllSettings()
|
||||||
private Response SaveSettings()
|
private Response SaveSettings()
|
||||||
{
|
{
|
||||||
var request = Request.Body.FromJson<Dictionary<string, object>>();
|
var request = Request.Body.FromJson<Dictionary<string, object>>();
|
||||||
|
_configService.SaveValues(request);
|
||||||
|
|
||||||
|
|
||||||
return request.AsResponse();
|
return request.AsResponse();
|
||||||
}
|
}
|
||||||
|
|
|
@ -593,6 +593,23 @@ public void SetValue(string key, string value)
|
||||||
ClearCache();
|
ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SaveValues(Dictionary<string, object> configValues)
|
||||||
|
{
|
||||||
|
//Todo: make this not suck - we need the pascal case of the key
|
||||||
|
//Todo: Can we batch save this without savig default values? Or do we care?
|
||||||
|
|
||||||
|
var allWithDefaults = AllWithDefaults();
|
||||||
|
|
||||||
|
foreach(var configValue in configValues)
|
||||||
|
{
|
||||||
|
object currentValue;
|
||||||
|
allWithDefaults.TryGetValue(configValue.Key, out currentValue);
|
||||||
|
|
||||||
|
if (!configValue.Equals(currentValue))
|
||||||
|
SetValue(configValue.Key, configValue.Value.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void EnsureCache()
|
private void EnsureCache()
|
||||||
{
|
{
|
||||||
lock (_cache)
|
lock (_cache)
|
||||||
|
|
|
@ -87,5 +87,6 @@ public interface IConfigService
|
||||||
PriorityType NzbgetRecentTvPriority { get; set; }
|
PriorityType NzbgetRecentTvPriority { get; set; }
|
||||||
string GetValue(string key, object defaultValue, bool persist = false);
|
string GetValue(string key, object defaultValue, bool persist = false);
|
||||||
void SetValue(string key, string value);
|
void SetValue(string key, string value);
|
||||||
|
void SaveValues(Dictionary<string, object> configValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue