misc
This commit is contained in:
parent
6a8c11b101
commit
4bdecabbe5
@ -13,17 +13,18 @@ pub fn load(config_path: PathBuf) -> Config {
|
||||
}
|
||||
|
||||
pub fn save(config_path: PathBuf, config: Config) {
|
||||
match fs::write(config_path.clone(), serde_json::to_string_pretty(&config).unwrap()) {
|
||||
match fs::write(
|
||||
config_path.clone(),
|
||||
serde_json::to_string_pretty(&config).unwrap(),
|
||||
) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
match e.kind() {
|
||||
Err(e) => match e.kind() {
|
||||
std::io::ErrorKind::NotFound => {
|
||||
fs::create_dir_all(config_path.parent().unwrap()).unwrap();
|
||||
return save(config_path, config);
|
||||
save(config_path, config);
|
||||
}
|
||||
_ => println!("Could not save config file, got:\n{}\n", e),
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::global;
|
||||
use crate::misc;
|
||||
use std::{fs, io::Write, path::Path, str};
|
||||
|
||||
@ -7,7 +8,11 @@ pub fn get_body(url: &str) -> Vec<u8> {
|
||||
match http_req::request::Request::new(&url.try_into().unwrap())
|
||||
.header(
|
||||
"User-Agent",
|
||||
"AlterWare Launcher | github.com/mxve/alterware-launcher",
|
||||
&format!(
|
||||
"AlterWare Launcher | github.com/{}/{}",
|
||||
global::GH_OWNER,
|
||||
global::GH_REPO
|
||||
),
|
||||
)
|
||||
.send(&mut res)
|
||||
{
|
||||
|
@ -29,8 +29,8 @@ pub fn run(_update_only: bool) {
|
||||
pub fn run(update_only: bool) {
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use crate::misc;
|
||||
use crate::http;
|
||||
use crate::misc;
|
||||
|
||||
let working_dir = std::env::current_dir().unwrap();
|
||||
let files = fs::read_dir(&working_dir).unwrap();
|
||||
@ -83,7 +83,10 @@ pub fn run(update_only: bool) {
|
||||
|
||||
self_replace::self_replace("alterware-launcher-update.exe").unwrap();
|
||||
fs::remove_file(&file_path).unwrap();
|
||||
println!("Launcher updated. View the changelog at https://github.com/{}/{}/releases/latest", GH_OWNER, GH_REPO,);
|
||||
println!(
|
||||
"Launcher updated. View the changelog at https://github.com/{}/{}/releases/latest",
|
||||
GH_OWNER, GH_REPO,
|
||||
);
|
||||
println!("Please restart the launcher.");
|
||||
if !update_only {
|
||||
misc::stdin();
|
||||
|
Loading…
Reference in New Issue
Block a user