From 6fcf4e7179dd4b5ca3bcfd921e43b1d749ff8f89 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Wed, 15 Jul 2020 11:38:43 +0300 Subject: [PATCH] Fix for restore ID issue --- components/common/cpp/src/configuration.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index 546db6eb9..a455a5c84 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -655,6 +655,19 @@ Configurable *ftl::config::configure(ftl::config::json_t &cfg) { return rootcfg; } +// Remove all $ keys from json +static void stripJSON(nlohmann::json &j) { + for(auto &el : j.items()) { + if (el.key()[0] == '$') { + j.erase(el.key()); + continue; + } + if (el.value().is_structured()) { + stripJSON(el.value()); + } + } +} + static std::atomic_bool doing_cleanup = false; void ftl::config::cleanup() { if (doing_cleanup) return; @@ -672,6 +685,7 @@ void ftl::config::cleanup() { } config_instance.clear(); + stripJSON(config_restore); ftl::saveJSON(std::string(FTL_LOCAL_CONFIG_ROOT "/")+cfg_root_str+std::string("_session.json"), config_restore); doing_cleanup = false; -- GitLab