fix(config): resolve ZEROCLAW_WORKSPACE root/workspace paths safely
This commit is contained in:
parent
b2976eb474
commit
a85a4a8194
1 changed files with 10 additions and 5 deletions
|
|
@ -1867,9 +1867,11 @@ pub(crate) fn persist_active_workspace_config_dir(config_dir: &Path) -> Result<(
|
|||
|
||||
fn resolve_config_dir_for_workspace(workspace_dir: &Path) -> (PathBuf, PathBuf) {
|
||||
let workspace_config_dir = workspace_dir.to_path_buf();
|
||||
let workspace_dir = workspace_dir.join("workspace").to_path_buf();
|
||||
if workspace_config_dir.join("config.toml").exists() {
|
||||
return (workspace_config_dir, workspace_dir);
|
||||
return (
|
||||
workspace_config_dir.clone(),
|
||||
workspace_config_dir.join("workspace"),
|
||||
);
|
||||
}
|
||||
|
||||
let legacy_config_dir = workspace_dir
|
||||
|
|
@ -1888,7 +1890,10 @@ fn resolve_config_dir_for_workspace(workspace_dir: &Path) -> (PathBuf, PathBuf)
|
|||
}
|
||||
}
|
||||
|
||||
(workspace_config_dir, workspace_dir)
|
||||
(
|
||||
workspace_config_dir.clone(),
|
||||
workspace_config_dir.join("workspace"),
|
||||
)
|
||||
}
|
||||
|
||||
fn decrypt_optional_secret(
|
||||
|
|
@ -3385,7 +3390,7 @@ default_temperature = 0.7
|
|||
|
||||
let config = Config::load_or_init().unwrap();
|
||||
|
||||
assert_eq!(config.workspace_dir, workspace_dir);
|
||||
assert_eq!(config.workspace_dir, workspace_dir.join("workspace"));
|
||||
assert_eq!(config.config_path, workspace_dir.join("config.toml"));
|
||||
assert!(workspace_dir.join("config.toml").exists());
|
||||
|
||||
|
|
@ -3518,7 +3523,7 @@ default_model = "legacy-model"
|
|||
|
||||
let config = Config::load_or_init().unwrap();
|
||||
|
||||
assert_eq!(config.workspace_dir, env_workspace_dir);
|
||||
assert_eq!(config.workspace_dir, env_workspace_dir.join("workspace"));
|
||||
assert_eq!(config.config_path, env_workspace_dir.join("config.toml"));
|
||||
|
||||
std::env::remove_var("ZEROCLAW_WORKSPACE");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue