From 0317faf09e4afcf32ec325cfeaf122db009e63da Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Tue, 6 Sep 2022 00:43:23 +0200 Subject: Implement update check for found Northstar install Also includes initial add of libthermite as dependency --- src-tauri/src/main.rs | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src-tauri/src') diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 34dcc39c..9dd15b55 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -104,9 +104,36 @@ fn get_northstar_version_number_caller() -> String { } #[tauri::command] -fn check_is_northstar_outdated() -> bool { - // TODO implement check - false +/// Checks if installed Northstar version is up-to-date +/// false -> Northstar install is up-to-date +/// true -> Northstar install is outdated +async fn check_is_northstar_outdated() -> bool { + let index = thermite::api::get_package_index().await.unwrap().to_vec(); + let nmod = index + .iter() + .find(|f| f.name.to_lowercase() == "northstar") + .unwrap(); + // .ok_or_else(|| anyhow!("Couldn't find Northstar on thunderstore???"))?; + + dbg!(nmod); + + let version_number = match get_northstar_version_number() { + Ok(version_number) => version_number, + Err(err) => { + println!("{}",err); + // If we fail to get new version just assume we are up-to-date + return false; + } + }; + + if version_number != nmod.version { + println!("Installed Northstar version outdated"); + true + } + else { + println!("Installed Northstar version up-to-date"); + false + } } #[tauri::command] -- cgit v1.2.3