mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 22:59:27 +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),
|
address: String::with_capacity(95),
|
||||||
},
|
},
|
||||||
version: Arc::new(Mutex::new(Version {
|
version: Arc::new(Mutex::new(Version {
|
||||||
|
gupax: Arc::new(Mutex::new(GUPAX_VERSION.to_string())),
|
||||||
p2pool: Arc::new(Mutex::new(P2POOL_VERSION.to_string())),
|
p2pool: Arc::new(Mutex::new(P2POOL_VERSION.to_string())),
|
||||||
xmrig: Arc::new(Mutex::new(XMRIG_VERSION.to_string())),
|
xmrig: Arc::new(Mutex::new(XMRIG_VERSION.to_string())),
|
||||||
})),
|
})),
|
||||||
|
@ -551,6 +552,7 @@ pub struct Xmrig {
|
||||||
|
|
||||||
#[derive(Clone,Debug,Deserialize,Serialize)]
|
#[derive(Clone,Debug,Deserialize,Serialize)]
|
||||||
pub struct Version {
|
pub struct Version {
|
||||||
|
pub gupax: Arc<Mutex<String>>,
|
||||||
pub p2pool: Arc<Mutex<String>>,
|
pub p2pool: Arc<Mutex<String>>,
|
||||||
pub xmrig: Arc<Mutex<String>>,
|
pub xmrig: Arc<Mutex<String>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -643,15 +643,18 @@ impl eframe::App for App {
|
||||||
// Error/Quit screen
|
// Error/Quit screen
|
||||||
match self.error_state.buttons {
|
match self.error_state.buttons {
|
||||||
StayQuit => {
|
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.update.lock().unwrap().updating.lock().unwrap() { text = format!("{}\nUpdate is in progress...!", text); }
|
||||||
if self.p2pool { text = format!("{}\nP2Pool is online...!", text); }
|
if self.p2pool { text = format!("{}\nP2Pool is online...!", text); }
|
||||||
if self.xmrig { text = format!("{}\nXMRig 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(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::*;
|
use ErrorButtons::*;
|
||||||
let height = ui.available_height();
|
let height = ui.available_height();
|
||||||
|
|
||||||
|
|
|
@ -418,40 +418,41 @@ impl Update {
|
||||||
let mut new_pkgs = vec![];
|
let mut new_pkgs = vec![];
|
||||||
for pkg in vec2.iter() {
|
for pkg in vec2.iter() {
|
||||||
let new_ver = pkg.new_ver.lock().unwrap().to_owned();
|
let new_ver = pkg.new_ver.lock().unwrap().to_owned();
|
||||||
|
let diff;
|
||||||
|
let old_ver;
|
||||||
|
let name;
|
||||||
match pkg.name {
|
match pkg.name {
|
||||||
Gupax => {
|
Gupax => {
|
||||||
if new_ver == GUPAX_VERSION {
|
old_ver = og_ver.lock().unwrap().gupax.lock().unwrap().to_string();
|
||||||
info!("Update | {} {} == {} ... SKIPPING", pkg.name, GUPAX_VERSION, new_ver);
|
// Compare against the built-in compiled version as well as a in-memory version
|
||||||
} else {
|
// that gets updated during an update. This prevents the updater always thinking
|
||||||
info!("Update | {} {} != {} ... ADDING", pkg.name, GUPAX_VERSION, new_ver);
|
// there's a new Gupax update since the user didnt restart and is still technically
|
||||||
new_pkgs.push(format!("\nGupax {} ➡ {}", GUPAX_VERSION, new_ver));
|
// using the old version (even though the underlying binary was updated).
|
||||||
vec3.push(pkg);
|
diff = old_ver != new_ver && GUPAX_VERSION != new_ver;
|
||||||
}
|
name = "Gupax";
|
||||||
}
|
}
|
||||||
P2pool => {
|
P2pool => {
|
||||||
let old_ver = og_ver.lock().unwrap().p2pool.lock().unwrap().to_owned();
|
old_ver = og_ver.lock().unwrap().p2pool.lock().unwrap().to_string();
|
||||||
if old_ver == new_ver {
|
diff = old_ver != new_ver;
|
||||||
info!("Update | {} {} == {} ... SKIPPING", pkg.name, old_ver, new_ver);
|
name = "P2Pool";
|
||||||
} else {
|
|
||||||
info!("Update | {} {} != {} ... ADDING", pkg.name, old_ver, new_ver);
|
|
||||||
new_pkgs.push(format!("\nP2Pool {} ➡ {}", old_ver, new_ver));
|
|
||||||
vec3.push(pkg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Xmrig => {
|
Xmrig => {
|
||||||
let old_ver = og_ver.lock().unwrap().xmrig.lock().unwrap().to_owned();
|
old_ver = og_ver.lock().unwrap().xmrig.lock().unwrap().to_string();
|
||||||
if old_ver == new_ver {
|
diff = old_ver != new_ver;
|
||||||
info!("Update | {} {} == {} ... SKIPPING", pkg.name, old_ver, new_ver);
|
name = "XMRig";
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
if diff {
|
||||||
info!("Update | {} {} != {} ... ADDING", pkg.name, old_ver, new_ver);
|
info!("Update | {} {} != {} ... ADDING", pkg.name, old_ver, new_ver);
|
||||||
new_pkgs.push(format!("\nXMRig {} ➡ {}", old_ver, new_ver));
|
new_pkgs.push(format!("\n{} {} -> {}", name, old_ver, new_ver));
|
||||||
vec3.push(pkg);
|
vec3.push(pkg);
|
||||||
}
|
} else {
|
||||||
}
|
info!("Update | {} {} == {} ... SKIPPING", pkg.name, old_ver, new_ver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*update.lock().unwrap().prog.lock().unwrap() += 5.0;
|
*update.lock().unwrap().prog.lock().unwrap() += 5.0;
|
||||||
info!("Update | Compare ... OK ... {}%", update.lock().unwrap().prog.lock().unwrap());
|
info!("Update | Compare ... OK ... {}%", update.lock().unwrap().prog.lock().unwrap());
|
||||||
|
|
||||||
// Return if 0 (all packages up-to-date)
|
// Return if 0 (all packages up-to-date)
|
||||||
// Get amount of packages to divide up the percentage increases
|
// Get amount of packages to divide up the percentage increases
|
||||||
let pkg_amount = vec3.len() as f32;
|
let pkg_amount = vec3.len() as f32;
|
||||||
|
@ -576,6 +577,7 @@ impl Update {
|
||||||
std::fs::rename(&path, tmp_windows)?;
|
std::fs::rename(&path, tmp_windows)?;
|
||||||
info!("Update | Moving [{}] -> [{}]", entry.path().display(), path);
|
info!("Update | Moving [{}] -> [{}]", entry.path().display(), path);
|
||||||
std::fs::rename(entry.path(), 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();
|
*update.lock().unwrap().prog.lock().unwrap() += (5.0 / pkg_amount).round();
|
||||||
},
|
},
|
||||||
P2POOL_BINARY => {
|
P2POOL_BINARY => {
|
||||||
|
|
Loading…
Reference in a new issue