Skip to content

Commit

Permalink
auto-updates: Do not poll for updates on dev channel (#13311)
Browse files Browse the repository at this point in the history
Our dev builds don't have updates and will never have updates, so
instead of polling our servers every time we start a dev instance, let's
disable it for the dev channel.

Release Notes:

- N/A
  • Loading branch information
mrnugget committed Jun 20, 2024
1 parent f5f73ef commit c20a1ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/auto_update/src/auto_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ pub fn init(http_client: Arc<HttpClientWithUrl>, cx: &mut AppContext) {
let auto_updater = cx.new_model(|cx| {
let updater = AutoUpdater::new(version, http_client);

let poll_for_updates = ReleaseChannel::try_global(cx)
.map(|channel| channel.poll_for_updates())
.unwrap_or(false);

if option_env!("ZED_UPDATE_EXPLANATION").is_none()
&& env::var("ZED_UPDATE_EXPLANATION").is_err()
&& poll_for_updates
{
let mut update_subscription = AutoUpdateSetting::get_global(cx)
.0
Expand Down Expand Up @@ -186,6 +191,13 @@ pub fn check(_: &Check, cx: &mut WindowContext) {
return;
}

if !ReleaseChannel::try_global(cx)
.map(|channel| channel.poll_for_updates())
.unwrap_or(false)
{
return;
}

if let Some(updater) = AutoUpdater::get(cx) {
updater.update(cx, |updater, cx| updater.poll(cx));
} else {
Expand Down
8 changes: 8 additions & 0 deletions crates/release_channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ impl ReleaseChannel {
.map(|channel| channel.0)
}

/// Returns whether we want to poll for updates for this [`ReleaseChannel`]
pub fn poll_for_updates(&self) -> bool {
match self {
ReleaseChannel::Dev => false,
_ => true,
}
}

/// Returns the display name for this [`ReleaseChannel`].
pub fn display_name(&self) -> &'static str {
match self {
Expand Down

0 comments on commit c20a1ee

Please sign in to comment.