mirror of
https://github.com/hinto-janai/gupax.git
synced 2024-11-17 09:47:36 +00:00
update: use compiled + updated version in gupax version comparison
If the built-in compiled version of Gupax is the only version getting compared when updating, an old Gupax instance will always think there's a new version even if the user already updated and the actual binaries are swapped. To prevent forcing users to restart, the built-in compiled version gets compared as well as the version stored in [Arc<Mutex<Version>>], which should get updated in a successful Gupax update.
This commit is contained in:
parent
bd6f369b56
commit
addf5ad60e
3 changed files with 33 additions and 26 deletions
|
@ -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<Mutex<String>>,
|
||||
pub p2pool: Arc<Mutex<String>>,
|
||||
pub xmrig: Arc<Mutex<String>>,
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 => {
|
||||
|
|
Loading…
Reference in a new issue