Skip to content

Commit

Permalink
check for required files
Browse files Browse the repository at this point in the history
  • Loading branch information
mxve committed Feb 7, 2024
1 parent 2760e2a commit e8aee89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ async fn update(
))
.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 hash_file = dir.join(".sha-sums");
if hash_file.exists() && !force {
Expand Down
16 changes: 16 additions & 0 deletions src/structs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::path::Path;

#[derive(serde::Deserialize, serde::Serialize, Clone)]
pub struct CdnFile {
pub name: String,
Expand All @@ -13,6 +15,20 @@ pub struct Game<'a> {
pub app_id: u32,
pub bonus: 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)]
Expand Down

0 comments on commit e8aee89

Please sign in to comment.