Attempt to fix rare crash writing configuration

This commit is contained in:
Kae 2023-07-05 21:31:36 +10:00
parent 54dfd900ca
commit 58678bfe9d
3 changed files with 7 additions and 1 deletions

View File

@ -16,6 +16,11 @@ Json Configuration::currentConfiguration() const {
return m_currentConfig;
}
String Configuration::printConfiguration() const {
MutexLocker locker(m_mutex);
return m_currentConfig.printJson(2, true);
}
Json Configuration::get(String const& key) const {
MutexLocker locker(m_mutex);
return m_currentConfig.get(key, {});

View File

@ -17,6 +17,7 @@ public:
Json defaultConfiguration() const;
Json currentConfiguration() const;
String printConfiguration() const;
Json get(String const& key) const;
Json getPath(String const& path) const;

View File

@ -678,7 +678,7 @@ void Root::writeConfig() {
if (m_lastRuntimeConfig != currentConfig) {
if (m_runtimeConfigFile) {
Logger::info("Root: Writing runtime configuration to '{}'", *m_runtimeConfigFile);
File::overwriteFileWithRename(currentConfig.printJson(2, true), *m_runtimeConfigFile);
File::overwriteFileWithRename(m_configuration->printConfiguration(), *m_runtimeConfigFile);
}
m_lastRuntimeConfig = currentConfig;
}