mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
chore: unify memory drop endpoints (#18134)
Unify all the memories drop behind a single implementation that drops both the main memories and the extensions
This commit is contained in:
@@ -49,6 +49,7 @@ use crate::mcp_cmd::McpCli;
|
||||
use crate::responses_cmd::ResponsesCommand;
|
||||
use crate::responses_cmd::run_responses_command;
|
||||
|
||||
use codex_core::clear_memory_roots_contents;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::ConfigOverrides;
|
||||
use codex_core::config::edit::ConfigEditsBuilder;
|
||||
@@ -1282,27 +1283,17 @@ async fn run_debug_clear_memories_command(
|
||||
cleared_state_db = true;
|
||||
}
|
||||
|
||||
let memory_root = config.codex_home.join("memories");
|
||||
let removed_memory_root = match tokio::fs::remove_dir_all(&memory_root).await {
|
||||
Ok(()) => true,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => false,
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
clear_memory_roots_contents(&config.codex_home).await?;
|
||||
|
||||
let mut message = if cleared_state_db {
|
||||
format!("Cleared memory state from {}.", state_path.display())
|
||||
} else {
|
||||
format!("No state db found at {}.", state_path.display())
|
||||
};
|
||||
|
||||
if removed_memory_root {
|
||||
message.push_str(&format!(" Removed {}.", memory_root.display()));
|
||||
} else {
|
||||
message.push_str(&format!(
|
||||
" No memory directory found at {}.",
|
||||
memory_root.display()
|
||||
));
|
||||
}
|
||||
message.push_str(&format!(
|
||||
" Cleared memory directories under {}.",
|
||||
config.codex_home.display()
|
||||
));
|
||||
|
||||
println!("{message}");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user