MCPcopy Create free account
hub / github.com/encounter/objdiff / run_check_update

Function run_check_update

objdiff-core/src/jobs/check_update.rs:22–43  ·  view source on GitHub ↗
(
    context: &JobContext,
    cancel: Receiver<()>,
    config: CheckUpdateConfig,
)

Source from the content-addressed store, hash-verified

20}
21
22fn 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
45pub fn start_check_update(waker: Waker, config: CheckUpdateConfig) -> JobState {
46 start_job(waker, "Check for updates", Job::CheckUpdate, move |context, cancel| {

Callers 1

start_check_updateFunction · 0.85

Calls 1

update_statusFunction · 0.85

Tested by

no test coverage detected