Fix update status logic to preserve previous status (#31202)
Release Notes: - N/A
This commit is contained in:
parent
e3d3daec92
commit
b188e5d3aa
1 changed files with 13 additions and 8 deletions
|
@ -492,10 +492,8 @@ impl AutoUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
|
async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
|
||||||
let (client, installed_version, status, release_channel) =
|
let (client, installed_version, previous_status, release_channel) =
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.status = AutoUpdateStatus::Checking;
|
|
||||||
cx.notify();
|
|
||||||
(
|
(
|
||||||
this.http_client.clone(),
|
this.http_client.clone(),
|
||||||
this.current_version,
|
this.current_version,
|
||||||
|
@ -504,6 +502,11 @@ impl AutoUpdater {
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.status = AutoUpdateStatus::Checking;
|
||||||
|
cx.notify();
|
||||||
|
})?;
|
||||||
|
|
||||||
let fetched_release_data =
|
let fetched_release_data =
|
||||||
Self::get_latest_release(&this, "zed", OS, ARCH, release_channel, &mut cx).await?;
|
Self::get_latest_release(&this, "zed", OS, ARCH, release_channel, &mut cx).await?;
|
||||||
let fetched_version = fetched_release_data.clone().version;
|
let fetched_version = fetched_release_data.clone().version;
|
||||||
|
@ -512,16 +515,18 @@ impl AutoUpdater {
|
||||||
*RELEASE_CHANNEL,
|
*RELEASE_CHANNEL,
|
||||||
app_commit_sha,
|
app_commit_sha,
|
||||||
installed_version,
|
installed_version,
|
||||||
status,
|
previous_status.clone(),
|
||||||
fetched_version,
|
fetched_version,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let Some(newer_version) = newer_version else {
|
let Some(newer_version) = newer_version else {
|
||||||
return this.update(&mut cx, |this, cx| {
|
return this.update(&mut cx, |this, cx| {
|
||||||
if !matches!(this.status, AutoUpdateStatus::Updated { .. }) {
|
let status = match previous_status {
|
||||||
this.status = AutoUpdateStatus::Idle;
|
AutoUpdateStatus::Updated { .. } => previous_status,
|
||||||
cx.notify();
|
_ => AutoUpdateStatus::Idle,
|
||||||
}
|
};
|
||||||
|
this.status = status;
|
||||||
|
cx.notify();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue