This reverts commit 5c4f9e57d8
.
Release Notes:
- N/A
This commit is contained in:
parent
6c8f4002d9
commit
636eff2e9a
2 changed files with 24 additions and 63 deletions
|
@ -485,7 +485,7 @@ impl ActivityIndicator {
|
||||||
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
this.dismiss_error_message(&DismissErrorMessage, window, cx)
|
||||||
})),
|
})),
|
||||||
}),
|
}),
|
||||||
AutoUpdateStatus::Updated { binary_path, .. } => Some(Content {
|
AutoUpdateStatus::Updated { binary_path } => Some(Content {
|
||||||
icon: None,
|
icon: None,
|
||||||
message: "Click to restart and update Zed".to_string(),
|
message: "Click to restart and update Zed".to_string(),
|
||||||
on_click: Some(Arc::new({
|
on_click: Some(Arc::new({
|
||||||
|
|
|
@ -39,22 +39,13 @@ struct UpdateRequestBody {
|
||||||
destination: &'static str,
|
destination: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
|
||||||
pub enum VersionCheckType {
|
|
||||||
Sha(String),
|
|
||||||
Semantic(SemanticVersion),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq)]
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
pub enum AutoUpdateStatus {
|
pub enum AutoUpdateStatus {
|
||||||
Idle,
|
Idle,
|
||||||
Checking,
|
Checking,
|
||||||
Downloading,
|
Downloading,
|
||||||
Installing,
|
Installing,
|
||||||
Updated {
|
Updated { binary_path: PathBuf },
|
||||||
binary_path: PathBuf,
|
|
||||||
version: VersionCheckType,
|
|
||||||
},
|
|
||||||
Errored,
|
Errored,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +62,7 @@ pub struct AutoUpdater {
|
||||||
pending_poll: Option<Task<Option<()>>>,
|
pending_poll: Option<Task<Option<()>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Clone, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct JsonRelease {
|
pub struct JsonRelease {
|
||||||
pub version: String,
|
pub version: String,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
@ -316,7 +307,7 @@ impl AutoUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&mut self, cx: &mut Context<Self>) {
|
pub fn poll(&mut self, cx: &mut Context<Self>) {
|
||||||
if self.pending_poll.is_some() {
|
if self.pending_poll.is_some() || self.status.is_updated() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,63 +482,36 @@ impl AutoUpdater {
|
||||||
Self::get_release(this, asset, os, arch, None, release_channel, cx).await
|
Self::get_release(this, asset, os, arch, None, release_channel, cx).await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn installed_update_version(&self) -> Option<VersionCheckType> {
|
|
||||||
match &self.status {
|
|
||||||
AutoUpdateStatus::Updated { version, .. } => Some(version.clone()),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
|
async fn update(this: Entity<Self>, mut cx: AsyncApp) -> Result<()> {
|
||||||
let (client, current_version, installed_update_version, release_channel) =
|
let (client, current_version, release_channel) = this.update(&mut cx, |this, cx| {
|
||||||
this.update(&mut cx, |this, cx| {
|
this.status = AutoUpdateStatus::Checking;
|
||||||
this.status = AutoUpdateStatus::Checking;
|
cx.notify();
|
||||||
cx.notify();
|
(
|
||||||
(
|
this.http_client.clone(),
|
||||||
this.http_client.clone(),
|
this.current_version,
|
||||||
this.current_version,
|
ReleaseChannel::try_global(cx),
|
||||||
this.installed_update_version(),
|
)
|
||||||
ReleaseChannel::try_global(cx),
|
})?;
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let release =
|
let release =
|
||||||
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 update_version_to_install = match *RELEASE_CHANNEL {
|
let should_download = match *RELEASE_CHANNEL {
|
||||||
ReleaseChannel::Nightly => {
|
ReleaseChannel::Nightly => cx
|
||||||
let should_download = cx
|
.update(|cx| AppCommitSha::try_global(cx).map(|sha| release.version != sha.0))
|
||||||
.update(|cx| AppCommitSha::try_global(cx).map(|sha| release.version != sha.0))
|
.ok()
|
||||||
.ok()
|
.flatten()
|
||||||
.flatten()
|
.unwrap_or(true),
|
||||||
.unwrap_or(true);
|
_ => release.version.parse::<SemanticVersion>()? > current_version,
|
||||||
|
|
||||||
should_download.then(|| VersionCheckType::Sha(release.version.clone()))
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
let installed_version =
|
|
||||||
installed_update_version.unwrap_or(VersionCheckType::Semantic(current_version));
|
|
||||||
match installed_version {
|
|
||||||
VersionCheckType::Sha(_) => {
|
|
||||||
log::warn!("Unexpected SHA-based version in non-nightly build");
|
|
||||||
Some(installed_version)
|
|
||||||
}
|
|
||||||
VersionCheckType::Semantic(semantic_comparison_version) => {
|
|
||||||
let latest_release_version = release.version.parse::<SemanticVersion>()?;
|
|
||||||
let should_download = latest_release_version > semantic_comparison_version;
|
|
||||||
should_download.then(|| VersionCheckType::Semantic(latest_release_version))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(update_version) = update_version_to_install else {
|
if !should_download {
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.status = AutoUpdateStatus::Idle;
|
this.status = AutoUpdateStatus::Idle;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
}
|
||||||
|
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.status = AutoUpdateStatus::Downloading;
|
this.status = AutoUpdateStatus::Downloading;
|
||||||
|
@ -569,7 +533,7 @@ impl AutoUpdater {
|
||||||
);
|
);
|
||||||
|
|
||||||
let downloaded_asset = installer_dir.path().join(filename);
|
let downloaded_asset = installer_dir.path().join(filename);
|
||||||
download_release(&downloaded_asset, release.clone(), client, &cx).await?;
|
download_release(&downloaded_asset, release, client, &cx).await?;
|
||||||
|
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.status = AutoUpdateStatus::Installing;
|
this.status = AutoUpdateStatus::Installing;
|
||||||
|
@ -586,10 +550,7 @@ impl AutoUpdater {
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.set_should_show_update_notification(true, cx)
|
this.set_should_show_update_notification(true, cx)
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
this.status = AutoUpdateStatus::Updated {
|
this.status = AutoUpdateStatus::Updated { binary_path };
|
||||||
binary_path,
|
|
||||||
version: update_version,
|
|
||||||
};
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue