codex: Delete older versions after installing new one (#41191)
Release Notes: - codex: Fixed an issue where downloading a new version would not delete older versions
This commit is contained in:
@@ -79,8 +79,6 @@ impl AgentServer for Codex {
|
||||
root_dir.as_deref(),
|
||||
extra_env,
|
||||
delegate.status_tx,
|
||||
// For now, report that there are no updates.
|
||||
// (A future PR will use the GitHub Releases API to fetch them.)
|
||||
delegate.new_version_available,
|
||||
&mut cx.to_async(),
|
||||
))
|
||||
|
||||
@@ -1212,7 +1212,7 @@ impl ExternalAgentServer for LocalCodex {
|
||||
&mut self,
|
||||
root_dir: Option<&str>,
|
||||
extra_env: HashMap<String, String>,
|
||||
_status_tx: Option<watch::Sender<SharedString>>,
|
||||
status_tx: Option<watch::Sender<SharedString>>,
|
||||
_new_version_available_tx: Option<watch::Sender<Option<String>>>,
|
||||
cx: &mut AsyncApp,
|
||||
) -> Task<Result<(AgentServerCommand, String, Option<task::SpawnInTerminal>)>> {
|
||||
@@ -1261,6 +1261,10 @@ impl ExternalAgentServer for LocalCodex {
|
||||
|
||||
let version_dir = dir.join(&release.tag_name);
|
||||
if !fs.is_dir(&version_dir).await {
|
||||
if let Some(mut status_tx) = status_tx {
|
||||
status_tx.send("Installing…".into()).ok();
|
||||
}
|
||||
|
||||
let tag = release.tag_name.clone();
|
||||
let version_number = tag.trim_start_matches('v');
|
||||
let asset_name = asset_name(version_number)
|
||||
@@ -1287,6 +1291,9 @@ impl ExternalAgentServer for LocalCodex {
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
// remove older versions
|
||||
util::fs::remove_matching(&dir, |entry| entry != version_dir).await;
|
||||
}
|
||||
|
||||
let bin_name = if cfg!(windows) {
|
||||
|
||||
Reference in New Issue
Block a user