From f02a925e3fdd1d4ce320253c1248a3602f7e2851 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 1 Jan 2025 18:50:47 +0100 Subject: [PATCH] refactor: remove password-less wrapper function for OSB files --- src/commands.rs | 11 ++--------- src/unzip_osb.rs | 8 +++----- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 80dab36..bc4d338 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -317,15 +317,8 @@ pub fn handle(command: SubCommand) -> Result<(), Box> { password, dir, } => { - use crate::unzip_osb::{unzip_osb, unzip_osb_using_password}; - match password { - Some(password) => unzip_osb_using_password( - file.as_str(), - dir.unwrap_or_default().as_str(), - password.as_str(), - ), - None => unzip_osb(file.as_str(), dir.unwrap_or_default().as_str()), - } + use crate::unzip_osb::unzip_osb; + unzip_osb(file.as_str(), dir.unwrap_or_default().as_str(), password) } } diff --git a/src/unzip_osb.rs b/src/unzip_osb.rs index ff08eed..e308218 100644 --- a/src/unzip_osb.rs +++ b/src/unzip_osb.rs @@ -45,7 +45,9 @@ macro_rules! error { }; } -pub fn unzip_osb_using_password(path: &str, dir: &str, password: &str) { +pub fn unzip_osb(path: &str, dir: &str, password: Option) { + let password = password.unwrap_or_else(|| deobfuscate(env!("OSB_KEY").trim())); + println!("Entpacke OSB-Datei {}\n", style(path).yellow()); let file = match fs::File::open(path) { @@ -125,7 +127,3 @@ pub fn unzip_osb_using_password(path: &str, dir: &str, password: &str) { } } } - -pub fn unzip_osb(path: &str, dir: &str) { - unzip_osb_using_password(path, dir, deobfuscate(env!("OSB_KEY").trim()).as_str()); -}