From aa61f4acf1e3e372b6d163f826fd139bcdc4463c Mon Sep 17 00:00:00 2001 From: DuProcess <273172371+DuProcess@users.noreply.github.com> Date: Thu, 16 Jul 2026 22:59:18 -0400 Subject: [PATCH] Clarify remote-only update checks --- src/bin/dosh-client.rs | 104 ++++++++++++++++++++++++++++++++++------- 1 file changed, 86 insertions(+), 18 deletions(-) diff --git a/src/bin/dosh-client.rs b/src/bin/dosh-client.rs index 3e01fd8..862abc6 100644 --- a/src/bin/dosh-client.rs +++ b/src/bin/dosh-client.rs @@ -4548,27 +4548,36 @@ fn run_update( } None => println!("latest: unknown"), } - if let Some(latest_url) = - local_installer_role.and_then(|_| latest_release_download_url(&repo, &artifact)) - { - let mut status = "missing"; - let mut display_url = latest_url.clone(); - if let Some(tag_url) = - effective_update_artifact_tag(local_version, latest_tag.as_deref()) - .as_deref() - .and_then(|tag| release_tag_download_url(&repo, tag, &artifact)) - { - display_url = tag_url; - if url_reachable(&display_url)? { + match local_prebuilt_check_target( + local_installer_role, + update_remote_server, + &repo, + &artifact, + ) { + LocalPrebuiltCheckTarget::Url(latest_url) => { + let mut status = "missing"; + let mut display_url = latest_url.clone(); + if let Some(tag_url) = + effective_update_artifact_tag(local_version, latest_tag.as_deref()) + .as_deref() + .and_then(|tag| release_tag_download_url(&repo, tag, &artifact)) + { + display_url = tag_url; + if url_reachable(&display_url)? { + status = "available"; + } + } else if url_reachable(&latest_url)? { status = "available"; } - } else if url_reachable(&latest_url)? { - status = "available"; + println!("prebuilt: {status} ({artifact})"); + println!("prebuilt_url: {display_url}"); + } + LocalPrebuiltCheckTarget::NonHttpRepo => { + println!("prebuilt: unavailable for non-HTTP repo"); + } + LocalPrebuiltCheckTarget::RemoteOnly => { + println!("prebuilt: skipped for remote-only update"); } - println!("prebuilt: {status} ({artifact})"); - println!("prebuilt_url: {display_url}"); - } else { - println!("prebuilt: unavailable for non-HTTP repo"); } return Ok(()); } @@ -4605,6 +4614,31 @@ fn run_update( Ok(()) } +#[derive(Debug, Clone, PartialEq, Eq)] +enum LocalPrebuiltCheckTarget { + Url(String), + NonHttpRepo, + RemoteOnly, +} + +fn local_prebuilt_check_target( + local_installer_role: Option<&str>, + update_remote_server: bool, + repo: &str, + artifact: &str, +) -> LocalPrebuiltCheckTarget { + if local_installer_role.is_none() { + return if update_remote_server { + LocalPrebuiltCheckTarget::RemoteOnly + } else { + LocalPrebuiltCheckTarget::NonHttpRepo + }; + } + latest_release_download_url(repo, artifact) + .map(LocalPrebuiltCheckTarget::Url) + .unwrap_or(LocalPrebuiltCheckTarget::NonHttpRepo) +} + fn run_update_installer( config: &dosh::config::ClientConfig, repo: &str, @@ -13139,6 +13173,40 @@ mod tests { assert!(!UpdateRole::Both.updates_remote_server_from_os("linux")); } + #[test] + fn update_check_distinguishes_remote_only_from_missing_local_prebuilt() { + assert_eq!( + super::local_prebuilt_check_target( + Some("client"), + false, + "https://git.palav.dev/Palav/dosh.git", + "dosh-windows-x86_64.zip", + ), + super::LocalPrebuiltCheckTarget::Url( + "https://git.palav.dev/Palav/dosh/releases/latest/download/dosh-windows-x86_64.zip" + .to_string() + ) + ); + assert_eq!( + super::local_prebuilt_check_target( + Some("client"), + false, + "git@git.palav.dev:Palav/dosh.git", + "dosh-windows-x86_64.zip", + ), + super::LocalPrebuiltCheckTarget::NonHttpRepo + ); + assert_eq!( + super::local_prebuilt_check_target( + UpdateRole::Server.local_installer_arg_for_os("windows"), + UpdateRole::Server.updates_remote_server_from_os("windows"), + "https://git.palav.dev/Palav/dosh.git", + "dosh-windows-x86_64.zip", + ), + super::LocalPrebuiltCheckTarget::RemoteOnly + ); + } + #[test] fn update_scripts_are_native_to_the_platform() { let config = ClientConfig {