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)] #[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() { match file.extension() {
Some(ex) => match ex.to_str() { Some(ex) => match ex.to_str() {
#[cfg(feature = "unzip-osb")] #[cfg(feature = "unzip-osb")]
Some("osb") => match password { Some("osb") => {
Some(password) => osb::check_file(file, password.as_str()), use deob::deobfuscate;
None => { osb::check_file(
use deob::deobfuscate; file,
osb::check_file(file, deobfuscate(env!("OSB_KEY").trim()).as_str()) &password.unwrap_or_else(|| deobfuscate(env!("OSB_KEY").trim())),
} )
}, }
Some("osc") => osc::check_file(file), Some("osc") => osc::check_file(file),
_ => Err(CheckNotice::Error { _ => Err(CheckNotice::Error {
description: "Keine prüfbare Datei".to_string(), description: "Keine prüfbare Datei".to_string(),

View File

@ -289,7 +289,7 @@ pub fn handle(command: SubCommand) -> Result<(), Box<dyn Error>> {
if list { if list {
print(); print();
} else { } 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) => { Ok(notices) => {
println!( println!(
"Es wurden {} Probleme gefunden\n", "Es wurden {} Probleme gefunden\n",