Compare commits

...

1 Commits

Author SHA1 Message Date
Peter Tripp
3c883df2f5 Suppress auto-update failures when offline 2025-06-12 16:59:22 -04:00
6 changed files with 35 additions and 10 deletions

1
Cargo.lock generated
View File

@@ -1167,6 +1167,7 @@ dependencies = [
"settings",
"smol",
"tempfile",
"util",
"which 6.0.3",
"workspace",
"workspace-hack",

View File

@@ -485,7 +485,7 @@ impl ActivityIndicator {
// Show any application auto-update info.
if let Some(updater) = &self.auto_updater {
return match &updater.read(cx).status() {
AutoUpdateStatus::Checking => Some(Content {
AutoUpdateStatus::Checking { .. } => Some(Content {
icon: Some(
Icon::new(IconName::Download)
.size(IconSize::Small)

View File

@@ -27,6 +27,7 @@ serde_json.workspace = true
settings.workspace = true
smol.workspace = true
tempfile.workspace = true
util.workspace = true
workspace.workspace = true
workspace-hack.workspace = true

View File

@@ -3,7 +3,8 @@ use client::{Client, TelemetrySettings};
use db::RELEASE_CHANNEL;
use db::kvp::KEY_VALUE_STORE;
use gpui::{
App, AppContext as _, AsyncApp, Context, Entity, Global, SemanticVersion, Task, Window, actions,
App, AppContext as _, AsyncApp, Context, Entity, Global, SemanticVersion, Task, Window,
actions, impl_actions,
};
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
use paths::remote_servers_dir;
@@ -23,12 +24,22 @@ use std::{
sync::Arc,
time::Duration,
};
use util::serde::default_true;
use workspace::Workspace;
const SHOULD_SHOW_UPDATE_NOTIFICATION_KEY: &str = "auto-updater-should-show-updated-notification";
const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
actions!(auto_update, [Check, DismissErrorMessage, ViewReleaseNotes,]);
actions!(auto_update, [DismissErrorMessage, ViewReleaseNotes,]);
#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Check {
#[serde(default = "default_true")]
pub manual: bool,
}
impl_actions!(auto_update, [Check]);
#[derive(Serialize)]
struct UpdateRequestBody {
@@ -48,7 +59,9 @@ pub enum VersionCheckType {
#[derive(Clone, PartialEq, Eq)]
pub enum AutoUpdateStatus {
Idle,
Checking,
Checking {
manual: bool,
},
Downloading {
version: VersionCheckType,
},
@@ -331,9 +344,19 @@ impl AutoUpdater {
this.update(cx, |this, cx| {
this.pending_poll = None;
if let Err(error) = result {
log::error!("auto-update failed: error:{:?}", error);
this.status = AutoUpdateStatus::Errored;
cx.notify();
match this.status {
// Be quiet if the check was automated (e.g. when offline)
AutoUpdateStatus::Checking { manual } if !manual => {
log::info!("auto-update check failed: error:{:?}", error);
this.status = AutoUpdateStatus::Idle;
cx.notify();
}
_ => {
log::error!("auto-update failed: error:{:?}", error);
this.status = AutoUpdateStatus::Errored;
cx.notify();
}
}
}
})
.ok()
@@ -507,7 +530,7 @@ impl AutoUpdater {
})?;
this.update(&mut cx, |this, cx| {
this.status = AutoUpdateStatus::Checking;
this.status = AutoUpdateStatus::Checking { manual: false };
cx.notify();
})?;

View File

@@ -660,7 +660,7 @@ impl TitleBar {
Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate",
Some(AutoUpdateStatus::Installing { .. })
| Some(AutoUpdateStatus::Downloading { .. })
| Some(AutoUpdateStatus::Checking) => "Updating...",
| Some(AutoUpdateStatus::Checking { .. }) => "Updating...",
Some(AutoUpdateStatus::Idle) | Some(AutoUpdateStatus::Errored) | None => {
"Please update Zed to Collaborate"
}

View File

@@ -10,7 +10,7 @@ pub fn app_menus() -> Vec<Menu> {
name: "Zed".into(),
items: vec![
MenuItem::action("About Zed…", zed_actions::About),
MenuItem::action("Check for Updates", auto_update::Check),
MenuItem::action("Check for Updates", auto_update::Check { manual: true }),
MenuItem::separator(),
MenuItem::submenu(Menu {
name: "Settings".into(),