(
context: &JobContext,
cancel: Receiver<()>,
config: CheckUpdateConfig,
)
| 20 | } |
| 21 | |
| 22 | fn run_check_update( |
| 23 | context: &JobContext, |
| 24 | cancel: Receiver<()>, |
| 25 | config: CheckUpdateConfig, |
| 26 | ) -> Result<Box<CheckUpdateResult>> { |
| 27 | update_status(context, "Fetching latest release".to_string(), 0, 1, &cancel)?; |
| 28 | let updater = (config.build_updater)().context("Failed to create release updater")?; |
| 29 | let latest_release = updater.get_latest_release()?; |
| 30 | let update_available = |
| 31 | self_update::version::bump_is_greater(cargo_crate_version!(), &latest_release.version)?; |
| 32 | // Find the binary name in the release assets |
| 33 | let mut found_binary = None; |
| 34 | for bin_name in &config.bin_names { |
| 35 | if latest_release.assets.iter().any(|a| &a.name == bin_name) { |
| 36 | found_binary = Some(bin_name.clone()); |
| 37 | break; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | update_status(context, "Complete".to_string(), 1, 1, &cancel)?; |
| 42 | Ok(Box::new(CheckUpdateResult { update_available, latest_release, found_binary })) |
| 43 | } |
| 44 | |
| 45 | pub fn start_check_update(waker: Waker, config: CheckUpdateConfig) -> JobState { |
| 46 | start_job(waker, "Check for updates", Job::CheckUpdate, move |context, cancel| { |
no test coverage detected