7 Commits

Author SHA1 Message Date
6ebb421a7b fix linux 2023-11-06 22:33:58 +01:00
6ef80be01f v0.6.2 2023-11-06 22:27:53 +01:00
1a3c090612 cleanup 2023-11-06 22:27:09 +01:00
fe7c8d2834 self restart 2023-11-06 03:20:46 +01:00
b3168b0a58 don't panic if cleaning up left over files fails 2023-11-06 02:08:29 +01:00
b1cffb44ad v0.6.1 2023-11-06 01:56:49 +01:00
5414213a19 fix existing file hashes always being calculated 2023-11-06 01:56:26 +01:00
4 changed files with 25 additions and 10 deletions

2
Cargo.lock generated
View File

@ -28,7 +28,7 @@ dependencies = [
[[package]] [[package]]
name = "alterware-launcher" name = "alterware-launcher"
version = "0.6.0" version = "0.6.2"
dependencies = [ dependencies = [
"colored", "colored",
"futures-util", "futures-util",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "alterware-launcher" name = "alterware-launcher"
version = "0.6.0" version = "0.6.2"
edition = "2021" edition = "2021"
build = "res/build.rs" build = "res/build.rs"

View File

@ -227,6 +227,7 @@ async fn update_dir(
"Checked".bright_blue(), "Checked".bright_blue(),
misc::cute_path(&file_path) misc::cute_path(&file_path)
)); ));
hashes.insert(file_name.to_owned(), file.hash.to_lowercase());
} }
} else { } else {
files_to_download.push(file.clone()); files_to_download.push(file.clone());
@ -373,7 +374,6 @@ fn arg_remove_value(args: &mut Vec<String>, arg: &str) {
async fn main() { async fn main() {
#[cfg(windows)] #[cfg(windows)]
setup_env(); setup_env();
let mut args: Vec<String> = env::args().collect(); let mut args: Vec<String> = env::args().collect();
if arg_bool(&args, "--help") { if arg_bool(&args, "--help") {

View File

@ -25,6 +25,19 @@ pub fn run(_update_only: bool) {
} }
} }
#[cfg(windows)]
pub fn restart() -> std::io::Error {
use std::os::windows::process::CommandExt;
match std::process::Command::new(std::env::current_exe().unwrap())
.args(std::env::args().skip(1))
.creation_flags(0x00000010) // CREATE_NEW_CONSOLE
.spawn()
{
Ok(_) => std::process::exit(0),
Err(err) => err,
}
}
#[cfg(windows)] #[cfg(windows)]
pub fn run(update_only: bool) { pub fn run(update_only: bool) {
use std::{fs, path::PathBuf}; use std::{fs, path::PathBuf};
@ -43,7 +56,9 @@ pub fn run(update_only: bool) {
&& (file_name.contains(".__relocated__.exe") && (file_name.contains(".__relocated__.exe")
|| file_name.contains(".__selfdelete__.exe")) || file_name.contains(".__selfdelete__.exe"))
{ {
fs::remove_file(file.path()).unwrap(); fs::remove_file(file.path()).unwrap_or_else(|_| {
println!("Failed to remove old launcher file.");
});
} }
} }
@ -66,7 +81,7 @@ pub fn run(update_only: bool) {
} else { } else {
"alterware-launcher.exe" "alterware-launcher.exe"
}; };
println!("{}", launcher_name);
http::download_file( http::download_file(
&format!( &format!(
"{}/download/{}", "{}/download/{}",
@ -83,12 +98,12 @@ pub fn run(update_only: bool) {
self_replace::self_replace("alterware-launcher-update.exe").unwrap(); self_replace::self_replace("alterware-launcher-update.exe").unwrap();
fs::remove_file(&file_path).unwrap(); fs::remove_file(&file_path).unwrap();
println!(
"Launcher updated. View the changelog at https://github.com/{}/{}/releases/latest", // restarting spawns a new console, automation should manually restart on exit code 201
GH_OWNER, GH_REPO,
);
println!("Please restart the launcher.");
if !update_only { if !update_only {
let restart_error = restart().to_string();
println!("Failed to restart launcher: {}", restart_error);
println!("Please restart the launcher manually.");
misc::stdin(); misc::stdin();
} }
std::process::exit(201); std::process::exit(201);