check for required files
This commit is contained in:
parent
2760e2ab1e
commit
e8aee89f45
@ -300,6 +300,15 @@ async fn update(
|
|||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
if !game.required_files_exist(dir) {
|
||||||
|
println!(
|
||||||
|
"{}\nVerify game file integrity on Steam or reinstall the game.",
|
||||||
|
"Critical game files missing.".bright_red()
|
||||||
|
);
|
||||||
|
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
let mut hashes = HashMap::new();
|
let mut hashes = HashMap::new();
|
||||||
let hash_file = dir.join(".sha-sums");
|
let hash_file = dir.join(".sha-sums");
|
||||||
if hash_file.exists() && !force {
|
if hash_file.exists() && !force {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use std::path::Path;
|
||||||
|
|
||||||
#[derive(serde::Deserialize, serde::Serialize, Clone)]
|
#[derive(serde::Deserialize, serde::Serialize, Clone)]
|
||||||
pub struct CdnFile {
|
pub struct CdnFile {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@ -13,6 +15,20 @@ pub struct Game<'a> {
|
|||||||
pub app_id: u32,
|
pub app_id: u32,
|
||||||
pub bonus: Vec<&'a str>,
|
pub bonus: Vec<&'a str>,
|
||||||
pub delete: Vec<&'a str>,
|
pub delete: Vec<&'a str>,
|
||||||
|
pub required: Vec<&'a str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Game<'a> {
|
||||||
|
pub fn required_files_exist(&self, dir: &Path) -> bool {
|
||||||
|
for required_file in &self.required {
|
||||||
|
let file_path = dir.join(required_file);
|
||||||
|
if !file_path.exists() {
|
||||||
|
println!("Required file {} does not exist", file_path.display());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, serde::Serialize)]
|
#[derive(serde::Deserialize, serde::Serialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user