Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump libthermite from 0.7.1 to 0.8.1 in /src-tauri #954

Merged
merged 2 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ steamlocate = "2.0.0-beta.2"
# Error messages
anyhow = "1.0"
# libthermite for Northstar/mod install handling
libthermite = { version = "0.7.1", features = ["proton"] }
libthermite = { version = "0.8.1", features = ["proton"] }
# zip stuff
zip = "0.6.2"
# Regex
Expand Down
26 changes: 19 additions & 7 deletions src-tauri/src/mod_management/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use thermite::prelude::ThermiteError;
use crate::NorthstarMod;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::str::FromStr;
use std::string::ToString;
use std::{fs, path::PathBuf};
Expand Down Expand Up @@ -505,10 +506,14 @@ fn delete_older_versions(
/// Checks whether some mod is correctly formatted
/// Currently checks whether
/// - Some `mod.json` exists under `mods/*/mod.json`
fn fc_sanity_check(input: &&fs::File) -> bool {
fn fc_sanity_check(input: &&fs::File) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let mut archive = match zip::read::ZipArchive::new(*input) {
Ok(archive) => archive,
Err(_) => return false,
Err(_) => {
return Err(Box::new(ThermiteError::UnknownError(
"Failed reading zip file".into(),
)))
}
};

let mut has_mods = false;
Expand Down Expand Up @@ -538,14 +543,22 @@ fn fc_sanity_check(input: &&fs::File) -> bool {
if name.to_str().unwrap().contains(".dll") {
log::warn!("Plugin detected, prompting user");
if !plugins::plugin_prompt() {
return false; // Plugin detected and user denied install
return Err(Box::new(ThermiteError::UnknownError(
"Plugin detected and install denied".into(),
)));
}
}
}
}
}

has_mods && mod_json_exists
if has_mods && mod_json_exists {
Ok(())
} else {
Err(Box::new(ThermiteError::UnknownError(
"Mod not correctly formatted".into(),
)))
}
}

// Copied from `libtermite` source code and modified
Expand Down Expand Up @@ -643,9 +656,8 @@ pub async fn fc_download_mod_and_install(
Err(err) => {
log::warn!("libthermite couldn't install mod {thunderstore_mod_string} due to {err:?}",);
return match err {
ThermiteError::SanityError => Err(
"Mod failed sanity check during install. It's probably not correctly formatted"
.to_string(),
ThermiteError::SanityError(e) => Err(
format!("Mod failed sanity check during install. It's probably not correctly formatted. {}", e)
),
_ => Err(err.to_string()),
};
Expand Down
Loading