Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
9598ec3dfe | |||
37266207e7 | |||
e041df80c5 | |||
b157bcb2c2 | |||
beae0adce5 | |||
f9ec044a15 |
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@ -11,8 +11,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: taiki-e/create-gh-release-action@v1
|
- uses: taiki-e/create-gh-release-action@v1
|
||||||
env:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
draft: true
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
upload-assets:
|
upload-assets:
|
||||||
strategy:
|
strategy:
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -13,7 +13,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"http_req",
|
"http_req",
|
||||||
"mslnk",
|
"mslnk",
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "res/build.rs"
|
build = "res/build.rs"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "s"
|
opt-level = "s"
|
||||||
|
|
||||||
|
# Symbols are a nice thing
|
||||||
|
debug = true
|
||||||
|
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@ -35,4 +39,4 @@ winres = "0.1.12"
|
|||||||
[package.metadata.winres]
|
[package.metadata.winres]
|
||||||
OriginalFilename = "alterware-launcher.exe"
|
OriginalFilename = "alterware-launcher.exe"
|
||||||
FileDescription = "AlterWare Launcher"
|
FileDescription = "AlterWare Launcher"
|
||||||
ProductName = "AlterWare Launcher"
|
ProductName = "AlterWare Launcher"
|
||||||
|
31
src/main.rs
31
src/main.rs
@ -2,7 +2,6 @@ mod http;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use mslnk::ShellLink;
|
use mslnk::ShellLink;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
|
||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use std::{thread, time};
|
use std::{thread, time};
|
||||||
@ -27,13 +26,6 @@ struct Game<'a> {
|
|||||||
const MASTER: &str = "https://master.alterware.dev";
|
const MASTER: &str = "https://master.alterware.dev";
|
||||||
const REPO: &str = "mxve/alterware-launcher";
|
const REPO: &str = "mxve/alterware-launcher";
|
||||||
|
|
||||||
fn get_cache_buster() -> u64 {
|
|
||||||
match SystemTime::now().duration_since(UNIX_EPOCH) {
|
|
||||||
Ok(n) => n.as_secs(),
|
|
||||||
Err(_) => 1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_file_sha1(path: &PathBuf) -> String {
|
fn get_file_sha1(path: &PathBuf) -> String {
|
||||||
let mut sha1 = sha1_smol::Sha1::new();
|
let mut sha1 = sha1_smol::Sha1::new();
|
||||||
sha1.update(&fs::read(path).unwrap());
|
sha1.update(&fs::read(path).unwrap());
|
||||||
@ -176,8 +168,12 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
let game = games.iter().find(|&g| g.app_id == input).unwrap();
|
let game = games.iter().find(|&g| g.app_id == input).unwrap();
|
||||||
|
|
||||||
let launcher_path = std::env::current_exe().unwrap();
|
let launcher_path = std::env::current_exe().unwrap();
|
||||||
fs::copy(launcher_path, path.join("alterware-launcher.exe")).unwrap();
|
let target_path = path.join("alterware-launcher.exe");
|
||||||
println!("Launcher copied to {}", path.display());
|
|
||||||
|
if launcher_path != target_path {
|
||||||
|
fs::copy(launcher_path, target_path).unwrap();
|
||||||
|
println!("Launcher copied to {}", path.display());
|
||||||
|
}
|
||||||
setup_client_links(game, path);
|
setup_client_links(game, path);
|
||||||
|
|
||||||
println!("Create Desktop shortcut? (Y/n)");
|
println!("Create Desktop shortcut? (Y/n)");
|
||||||
@ -218,7 +214,7 @@ fn windows_launcher_install(games: &Vec<Game>) {
|
|||||||
|
|
||||||
fn update(game: &Game) {
|
fn update(game: &Game) {
|
||||||
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
||||||
format!("{}/files.json?{}", MASTER, get_cache_buster()).as_str(),
|
format!("{}/files.json", MASTER).as_str(),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -238,10 +234,7 @@ fn update(game: &Game) {
|
|||||||
sha1_local,
|
sha1_local,
|
||||||
sha1_remote
|
sha1_remote
|
||||||
);
|
);
|
||||||
http::download_file(
|
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
||||||
&format!("{}/{}?{}", MASTER, file.name, get_cache_buster()),
|
|
||||||
&file_path,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("Downloading {}...", file_path.display());
|
println!("Downloading {}...", file_path.display());
|
||||||
@ -250,10 +243,7 @@ fn update(game: &Game) {
|
|||||||
fs::create_dir_all(parent).unwrap();
|
fs::create_dir_all(parent).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
http::download_file(
|
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
||||||
&format!("{}/{}?{}", MASTER, file.name, get_cache_buster()),
|
|
||||||
&file_path,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,8 +268,7 @@ fn main() {
|
|||||||
.map(|e| args.remove(e));
|
.map(|e| args.remove(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
let games_json =
|
let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str());
|
||||||
http::get_body_string(format!("{}/games.json?{}", MASTER, get_cache_buster()).as_str());
|
|
||||||
let games: Vec<Game> = serde_json::from_str(&games_json).unwrap();
|
let games: Vec<Game> = serde_json::from_str(&games_json).unwrap();
|
||||||
|
|
||||||
let mut update_only = false;
|
let mut update_only = false;
|
||||||
|
Reference in New Issue
Block a user