diff --git a/src/disk.rs b/src/disk.rs index 932ac87..0a21194 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -171,6 +171,7 @@ impl State { address: String::with_capacity(95), }, version: Arc::new(Mutex::new(Version { + gupax: Arc::new(Mutex::new(GUPAX_VERSION.to_string())), p2pool: Arc::new(Mutex::new(P2POOL_VERSION.to_string())), xmrig: Arc::new(Mutex::new(XMRIG_VERSION.to_string())), })), @@ -551,6 +552,7 @@ pub struct Xmrig { #[derive(Clone,Debug,Deserialize,Serialize)] pub struct Version { + pub gupax: Arc>, pub p2pool: Arc>, pub xmrig: Arc>, } diff --git a/src/main.rs b/src/main.rs index 6787cf1..38389b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -643,15 +643,18 @@ impl eframe::App for App { // Error/Quit screen match self.error_state.buttons { StayQuit => { - let mut text = "--- Are you sure you want to quit? ---".to_string(); + let mut text = "".to_string(); if *self.update.lock().unwrap().updating.lock().unwrap() { text = format!("{}\nUpdate is in progress...!", text); } if self.p2pool { text = format!("{}\nP2Pool is online...!", text); } if self.xmrig { text = format!("{}\nXMRig is online...!", text); } + ui.add_sized([width, height], Label::new("--- Are you sure you want to quit? ---")); ui.add_sized([width, height], Label::new(text)) }, - _ => ui.add_sized([width, height], Label::new("--- Gupax has encountered an error! ---")), + _ => { + ui.add_sized([width, height], Label::new("--- Gupax has encountered an error! ---")); + ui.add_sized([width, height], Label::new(self.error_state.msg)) + }, }; - ui.add_sized([width, height], Label::new(self.error_state.msg)); use ErrorButtons::*; let height = ui.available_height(); diff --git a/src/update.rs b/src/update.rs index 16aea53..c04f525 100644 --- a/src/update.rs +++ b/src/update.rs @@ -418,40 +418,41 @@ impl Update { let mut new_pkgs = vec![]; for pkg in vec2.iter() { let new_ver = pkg.new_ver.lock().unwrap().to_owned(); + let diff; + let old_ver; + let name; match pkg.name { Gupax => { - if new_ver == GUPAX_VERSION { - info!("Update | {} {} == {} ... SKIPPING", pkg.name, GUPAX_VERSION, new_ver); - } else { - info!("Update | {} {} != {} ... ADDING", pkg.name, GUPAX_VERSION, new_ver); - new_pkgs.push(format!("\nGupax {} ➡ {}", GUPAX_VERSION, new_ver)); - vec3.push(pkg); - } + old_ver = og_ver.lock().unwrap().gupax.lock().unwrap().to_string(); + // Compare against the built-in compiled version as well as a in-memory version + // that gets updated during an update. This prevents the updater always thinking + // there's a new Gupax update since the user didnt restart and is still technically + // using the old version (even though the underlying binary was updated). + diff = old_ver != new_ver && GUPAX_VERSION != new_ver; + name = "Gupax"; } P2pool => { - let old_ver = og_ver.lock().unwrap().p2pool.lock().unwrap().to_owned(); - if old_ver == new_ver { - info!("Update | {} {} == {} ... SKIPPING", pkg.name, old_ver, new_ver); - } else { - info!("Update | {} {} != {} ... ADDING", pkg.name, old_ver, new_ver); - new_pkgs.push(format!("\nP2Pool {} ➡ {}", old_ver, new_ver)); - vec3.push(pkg); - } + old_ver = og_ver.lock().unwrap().p2pool.lock().unwrap().to_string(); + diff = old_ver != new_ver; + name = "P2Pool"; } Xmrig => { - let old_ver = og_ver.lock().unwrap().xmrig.lock().unwrap().to_owned(); - if old_ver == new_ver { - info!("Update | {} {} == {} ... SKIPPING", pkg.name, old_ver, new_ver); - } else { - info!("Update | {} {} != {} ... ADDING", pkg.name, old_ver, new_ver); - new_pkgs.push(format!("\nXMRig {} ➡ {}", old_ver, new_ver)); - vec3.push(pkg); - } + old_ver = og_ver.lock().unwrap().xmrig.lock().unwrap().to_string(); + diff = old_ver != new_ver; + name = "XMRig"; } } + if diff { + info!("Update | {} {} != {} ... ADDING", pkg.name, old_ver, new_ver); + new_pkgs.push(format!("\n{} {} -> {}", name, old_ver, new_ver)); + vec3.push(pkg); + } else { + info!("Update | {} {} == {} ... SKIPPING", pkg.name, old_ver, new_ver); + } } *update.lock().unwrap().prog.lock().unwrap() += 5.0; info!("Update | Compare ... OK ... {}%", update.lock().unwrap().prog.lock().unwrap()); + // Return if 0 (all packages up-to-date) // Get amount of packages to divide up the percentage increases let pkg_amount = vec3.len() as f32; @@ -576,6 +577,7 @@ impl Update { std::fs::rename(&path, tmp_windows)?; info!("Update | Moving [{}] -> [{}]", entry.path().display(), path); std::fs::rename(entry.path(), path)?; + *og_ver.lock().unwrap().gupax.lock().unwrap() = Pkg::get_new_pkg_version(Gupax, &vec4)?; *update.lock().unwrap().prog.lock().unwrap() += (5.0 / pkg_amount).round(); }, P2POOL_BINARY => {