From bc3d94a3830790c71a37533f4535046d73ae8fc1 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sat, 13 Apr 2024 16:21:34 +0800 Subject: [PATCH] fix: fix default config load --- src/ll/api/Config.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ll/api/Config.h b/src/ll/api/Config.h index 67193869bb..02720c8595 100644 --- a/src/ll/api/Config.h +++ b/src/ll/api/Config.h @@ -32,7 +32,11 @@ bool defaultConfigUpdater(T& config, J& data) { template inline bool loadConfig(T& config, std::filesystem::path const& path, F&& updater = defaultConfigUpdater) { bool noNeedRewrite = true; - auto content = file_utils::readFile(path); + namespace fs = std::filesystem; + if (!fs::exists(path)) { + saveConfig(config, path); + } + auto content = file_utils::readFile(path); if (content && !content->empty()) { auto data{J::parse(*content, nullptr, true, true)}; if (!data.contains("version")) {