mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
Update codex-rs/core/src/shell.rs
Co-authored-by: Michael Bolin <mbolin@openai.com>
This commit is contained in:
@@ -232,32 +232,26 @@ async fn ensure_zsh_snapshot(shell_path: &str, home: &Path, session_id: Uuid) ->
|
||||
let snapshot_path = home.join(format!(".codex_shell_snapshot_{session_id}.zsh"));
|
||||
|
||||
// Check if an update in the profile requires to re-generate the snapshot.
|
||||
let snapshot_is_stale = match tokio::fs::metadata(&snapshot_path).await {
|
||||
Ok(metadata) => match metadata.modified() {
|
||||
Ok(snapshot_modified) => {
|
||||
let mut stale = false;
|
||||
for profile in zsh_profile_paths(home) {
|
||||
if let Ok(profile_metadata) = tokio::fs::metadata(&profile).await {
|
||||
match profile_metadata.modified() {
|
||||
Ok(profile_modified) => {
|
||||
if profile_modified > snapshot_modified {
|
||||
stale = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
stale = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stale
|
||||
}
|
||||
Err(_) => true,
|
||||
},
|
||||
Err(_) => true,
|
||||
};
|
||||
let snapshot_is_stale = async {
|
||||
let snapshot_metadata = tokio::fs::metadata(&snapshot_path).await.ok()?;
|
||||
let snapshot_modified = snapshot_metadata.modified().ok()?;
|
||||
|
||||
for profile in zsh_profile_paths(home) {
|
||||
let Ok(profile_metadata) = tokio::fs::metadata(&profile).await else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let Ok(profile_modified) = profile_metadata.modified() else {
|
||||
return Some(true);
|
||||
};
|
||||
|
||||
if profile_modified > snapshot_modified {
|
||||
return Some(true);
|
||||
}
|
||||
}
|
||||
|
||||
Some(false)
|
||||
}.await.unwrap_or(true);
|
||||
|
||||
if !snapshot_is_stale {
|
||||
return Some(snapshot_path);
|
||||
|
||||
Reference in New Issue
Block a user