Restore missing configuration keys from default
This commit is contained in:
parent
24c2820ce1
commit
2ffd83c283
@ -391,13 +391,19 @@ ConfigurationPtr Root::configuration() {
|
|||||||
currentConfig = m_settings.defaultConfiguration;
|
currentConfig = m_settings.defaultConfiguration;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Json config = Json::parseJson(File::readFileString(*m_runtimeConfigFile));
|
Json jConfig = Json::parseJson(File::readFileString(*m_runtimeConfigFile));
|
||||||
if (!config.isType(Json::Type::Object))
|
if (!jConfig.isType(Json::Type::Object))
|
||||||
throw ConfigurationException("User config is not of JSON type Object");
|
throw ConfigurationException("User config is not of JSON type Object");
|
||||||
|
|
||||||
if (config.get("configurationVersion", {}) != m_settings.defaultConfiguration.get("configurationVersion", {}))
|
if (jConfig.get("configurationVersion", {}) != m_settings.defaultConfiguration.get("configurationVersion", {}))
|
||||||
throw ConfigurationException("User config version does not match default config version");
|
throw ConfigurationException("User config version does not match default config version");
|
||||||
|
|
||||||
|
auto config = jConfig.toObject();
|
||||||
|
for (auto& entry : *m_settings.defaultConfiguration.objectPtr()) {
|
||||||
|
if (!config.contains(entry.first))
|
||||||
|
config.insert(entry.first, entry.second);
|
||||||
|
}
|
||||||
|
|
||||||
currentConfig = config;
|
currentConfig = config;
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
Logger::warn("Root: Failed to load user configuration file {}, resetting user config: {}", *m_runtimeConfigFile, outputException(e, false));
|
Logger::warn("Root: Failed to load user configuration file {}, resetting user config: {}", *m_runtimeConfigFile, outputException(e, false));
|
||||||
|
Loading…
Reference in New Issue
Block a user