Silence failed auto update checks (#32696)
Don't immediately show "auto-update failed" errors in the status bar when launching zed offline or when a periodic auto-update check is triggered when you are offline. Manual checks (via menu or action) or errors after the initial version check succeeds (download/extraction failure) are unchanged. Supersedes: https://github.com/zed-industries/zed/pull/32643 Release Notes: - N/A Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
This commit is contained in:
parent
628f91dd96
commit
cf129aa19d
1 changed files with 20 additions and 5 deletions
|
@ -221,7 +221,7 @@ pub fn check(_: &Check, window: &mut Window, cx: &mut App) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(updater) = AutoUpdater::get(cx) {
|
if let Some(updater) = AutoUpdater::get(cx) {
|
||||||
updater.update(cx, |updater, cx| updater.poll(cx));
|
updater.update(cx, |updater, cx| updater.poll(UpdateCheckType::Manual, cx));
|
||||||
} else {
|
} else {
|
||||||
drop(window.prompt(
|
drop(window.prompt(
|
||||||
gpui::PromptLevel::Info,
|
gpui::PromptLevel::Info,
|
||||||
|
@ -296,6 +296,11 @@ impl InstallerDir {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum UpdateCheckType {
|
||||||
|
Automatic,
|
||||||
|
Manual,
|
||||||
|
}
|
||||||
|
|
||||||
impl AutoUpdater {
|
impl AutoUpdater {
|
||||||
pub fn get(cx: &mut App) -> Option<Entity<Self>> {
|
pub fn get(cx: &mut App) -> Option<Entity<Self>> {
|
||||||
cx.default_global::<GlobalAutoUpdate>().0.clone()
|
cx.default_global::<GlobalAutoUpdate>().0.clone()
|
||||||
|
@ -313,13 +318,13 @@ impl AutoUpdater {
|
||||||
pub fn start_polling(&self, cx: &mut Context<Self>) -> Task<Result<()>> {
|
pub fn start_polling(&self, cx: &mut Context<Self>) -> Task<Result<()>> {
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
loop {
|
loop {
|
||||||
this.update(cx, |this, cx| this.poll(cx))?;
|
this.update(cx, |this, cx| this.poll(UpdateCheckType::Automatic, cx))?;
|
||||||
cx.background_executor().timer(POLL_INTERVAL).await;
|
cx.background_executor().timer(POLL_INTERVAL).await;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&mut self, cx: &mut Context<Self>) {
|
pub fn poll(&mut self, check_type: UpdateCheckType, cx: &mut Context<Self>) {
|
||||||
if self.pending_poll.is_some() {
|
if self.pending_poll.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -331,8 +336,18 @@ impl AutoUpdater {
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
this.pending_poll = None;
|
this.pending_poll = None;
|
||||||
if let Err(error) = result {
|
if let Err(error) = result {
|
||||||
|
this.status = match check_type {
|
||||||
|
// Be quiet if the check was automated (e.g. when offline)
|
||||||
|
UpdateCheckType::Automatic => {
|
||||||
|
log::info!("auto-update check failed: error:{:?}", error);
|
||||||
|
AutoUpdateStatus::Idle
|
||||||
|
}
|
||||||
|
UpdateCheckType::Manual => {
|
||||||
log::error!("auto-update failed: error:{:?}", error);
|
log::error!("auto-update failed: error:{:?}", error);
|
||||||
this.status = AutoUpdateStatus::Errored;
|
AutoUpdateStatus::Errored
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue