mirror of
https://github.com/instructkr/claw-code.git
synced 2026-06-03 05:04:09 +08:00
fix(#698): dedup config deprecation warnings per process; add tempfile dev-dep to runtime crate (fixes pre-existing test compile error)
This commit is contained in:
@@ -16,5 +16,8 @@ telemetry = { path = "../telemetry" }
|
||||
tokio = { version = "1", features = ["io-std", "io-util", "macros", "process", "rt", "rt-multi-thread", "time"] }
|
||||
walkdir = "2"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
|
||||
/// Process-lifetime set of already-emitted config deprecation warning strings.
|
||||
/// Prevents duplicate warnings when `ConfigLoader::load()` is called multiple
|
||||
/// times within a single CLI invocation. (ROADMAP #698)
|
||||
static EMITTED_CONFIG_WARNINGS: std::sync::OnceLock<Mutex<HashSet<String>>> =
|
||||
std::sync::OnceLock::new();
|
||||
|
||||
fn emit_config_warning_once(warning: &str) {
|
||||
let set = EMITTED_CONFIG_WARNINGS.get_or_init(|| Mutex::new(HashSet::new()));
|
||||
let mut guard = set.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if guard.insert(warning.to_string()) {
|
||||
eprintln!("warning: {warning}");
|
||||
}
|
||||
}
|
||||
|
||||
use crate::json::JsonValue;
|
||||
use crate::sandbox::{FilesystemIsolationMode, SandboxConfig};
|
||||
@@ -301,7 +316,7 @@ impl ConfigLoader {
|
||||
}
|
||||
|
||||
for warning in &all_warnings {
|
||||
eprintln!("warning: {warning}");
|
||||
emit_config_warning_once(&warning.to_string());
|
||||
}
|
||||
|
||||
let merged_value = JsonValue::Object(merged.clone());
|
||||
|
||||
Reference in New Issue
Block a user