mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-19 19:56:50 +00:00
refactor: change usage of password dependent on feature selection
This commit is contained in:
parent
a70f72603f
commit
1215daca1e
@ -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()),
|
|
||||||
None => {
|
|
||||||
use deob::deobfuscate;
|
use deob::deobfuscate;
|
||||||
osb::check_file(file, deobfuscate(env!("OSB_KEY").trim()).as_str())
|
osb::check_file(
|
||||||
|
file,
|
||||||
|
&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(),
|
||||||
|
@ -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",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user