From 06f3933ce11c79dc0af713fb0ced5948fd038979 Mon Sep 17 00:00:00 2001 From: RubberDuckShobe <42943070+RubberDuckShobe@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:43:26 +0200 Subject: [PATCH] apparently i forgot to push the code that actually makes the updater work + Update README.md --- README.md | 1 + wavebreaker_client/Cargo.toml | 1 + wavebreaker_client/src/lib.rs | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index d3d239d..bc96b40 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ This enables Audiosurf to connect to [the public testing instance of Wavebreaker It *should* be able to connect to the official server as well, but that is *not* its primary intended use and keeping compatibility with the original server is not explicitly a goal of this project. ## Features +- Includes an automatic updater, so users don't have to re-run the installer every time. - Forces HTTPS for every request. - If present, the [MusicBrainz ID](https://musicbrainz.org/doc/MusicBrainz_Identifier) of the [recording](https://musicbrainz.org/doc/Recording) is sent to the server, if it's present in a song file's metadata. - Can optionally force HTTP (without the S) to aid in custom server development. diff --git a/wavebreaker_client/Cargo.toml b/wavebreaker_client/Cargo.toml index 85b0fc4..8e3b0a9 100644 --- a/wavebreaker_client/Cargo.toml +++ b/wavebreaker_client/Cargo.toml @@ -37,6 +37,7 @@ rfd = "0.14.1" octocrab = "0.38.0" semver = "1.0.22" tokio = { version = "1.37.0", features = ["full"] } +open = "5.1.2" [build-dependencies] bindgen = "0.69.4" diff --git a/wavebreaker_client/src/lib.rs b/wavebreaker_client/src/lib.rs index 23a659a..dc0f1b0 100644 --- a/wavebreaker_client/src/lib.rs +++ b/wavebreaker_client/src/lib.rs @@ -5,6 +5,7 @@ mod state; use std::{ ffi::{c_void, CString}, + path::Path, thread, }; @@ -72,8 +73,14 @@ async unsafe fn main() -> anyhow::Result<()> { "Current version {}, latest is tag_version {}", current_version, tag_version ); + if Path::exists(Path::new("./wavebreaker_up.exenew")) { + std::fs::rename("wavebreaker_up.exenew", "wavebreaker_up.exe") + .context("Failed to replace old updater with new one")?; + } + if tag_version > current_version { info!("New version {} available!", tag_version); + open::that_detached("./wavebreaker_up.exe").context("Failed to open updater")?; std::process::exit(0); //just kill the game } }