From dbae5e52586fb1336b973172d97c3d602a5d33d6 Mon Sep 17 00:00:00 2001 From: xiaozhou233 Date: Tue, 18 Aug 2026 20:11:00 +0800 Subject: [PATCH] Fix: do not auto-read config when runtime dir is empty Config no longer falls back to the current working directory when no runtime directory is specified, so an empty runtime dir leaves the config invalid instead of silently parsing config.toml from the CWD. --- includes/JuiceAgent/Config.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/JuiceAgent/Config.hpp b/includes/JuiceAgent/Config.hpp index 5f77a2e..fc86e35 100644 --- a/includes/JuiceAgent/Config.hpp +++ b/includes/JuiceAgent/Config.hpp @@ -15,9 +15,13 @@ class Config { public: explicit Config(const std::filesystem::path& runtime_dir = {}) { - _runtime_dir = runtime_dir.empty() - ? std::filesystem::current_path() - : runtime_dir; + _runtime_dir = runtime_dir; + + // No runtime directory specified: do not auto-read a config file + // from the current working directory. + if (runtime_dir.empty()) { + return; + } const auto result = toml::try_parse(_runtime_dir / "config.toml");