1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-04-19 11:46:50 +00:00

refactor: change usage of password dependent on feature selection

This commit is contained in:
Paul-Christian Volkmer 2025-01-01 20:09:36 +01:00
parent a70f72603f
commit 1215daca1e
2 changed files with 10 additions and 9 deletions

View File

@ -138,17 +138,18 @@ pub trait Fixable {
}
#[allow(unused_variables)]
pub fn check_file(file: &Path, password: &Option<String>) -> Result<Vec<CheckNotice>, CheckNotice> {
#[allow(clippy::needless_pass_by_value)]
pub fn check_file(file: &Path, password: Option<String>) -> Result<Vec<CheckNotice>, CheckNotice> {
match file.extension() {
Some(ex) => match ex.to_str() {
#[cfg(feature = "unzip-osb")]
Some("osb") => match password {
Some(password) => osb::check_file(file, password.as_str()),
None => {
use deob::deobfuscate;
osb::check_file(file, deobfuscate(env!("OSB_KEY").trim()).as_str())
}
},
Some("osb") => {
use deob::deobfuscate;
osb::check_file(
file,
&password.unwrap_or_else(|| deobfuscate(env!("OSB_KEY").trim())),
)
}
Some("osc") => osc::check_file(file),
_ => Err(CheckNotice::Error {
description: "Keine prüfbare Datei".to_string(),

View File

@ -289,7 +289,7 @@ pub fn handle(command: SubCommand) -> Result<(), Box<dyn Error>> {
if list {
print();
} else {
match check_file(Path::new(file.unwrap_or_default().as_str()), &password) {
match check_file(Path::new(file.unwrap_or_default().as_str()), password) {
Ok(notices) => {
println!(
"Es wurden {} Probleme gefunden\n",