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(),
|
root_dir.as_deref(),
|
||||||
extra_env,
|
extra_env,
|
||||||
delegate.status_tx,
|
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,
|
delegate.new_version_available,
|
||||||
&mut cx.to_async(),
|
&mut cx.to_async(),
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -1212,7 +1212,7 @@ impl ExternalAgentServer for LocalCodex {
|
|||||||
&mut self,
|
&mut self,
|
||||||
root_dir: Option<&str>,
|
root_dir: Option<&str>,
|
||||||
extra_env: HashMap<String, String>,
|
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>>>,
|
_new_version_available_tx: Option<watch::Sender<Option<String>>>,
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Task<Result<(AgentServerCommand, String, Option<task::SpawnInTerminal>)>> {
|
) -> Task<Result<(AgentServerCommand, String, Option<task::SpawnInTerminal>)>> {
|
||||||
@@ -1261,6 +1261,10 @@ impl ExternalAgentServer for LocalCodex {
|
|||||||
|
|
||||||
let version_dir = dir.join(&release.tag_name);
|
let version_dir = dir.join(&release.tag_name);
|
||||||
if !fs.is_dir(&version_dir).await {
|
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 tag = release.tag_name.clone();
|
||||||
let version_number = tag.trim_start_matches('v');
|
let version_number = tag.trim_start_matches('v');
|
||||||
let asset_name = asset_name(version_number)
|
let asset_name = asset_name(version_number)
|
||||||
@@ -1287,6 +1291,9 @@ impl ExternalAgentServer for LocalCodex {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// remove older versions
|
||||||
|
util::fs::remove_matching(&dir, |entry| entry != version_dir).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bin_name = if cfg!(windows) {
|
let bin_name = if cfg!(windows) {
|
||||||
|
|||||||
Reference in New Issue
Block a user