diff --git a/src/checks/osb.rs b/src/checks/osb.rs index 708c8ff..f1c3597 100644 --- a/src/checks/osb.rs +++ b/src/checks/osb.rs @@ -32,7 +32,7 @@ pub fn check_file(file: &Path, password: &str) -> Result, Check Ok(file) => file, Err(err) => { return Err(CheckNotice::Error { - description: format!("Kann Datei nicht lesen: {}", err), + description: format!("Kann Datei nicht lesen: {err}"), line: None, }); } @@ -42,7 +42,7 @@ pub fn check_file(file: &Path, password: &str) -> Result, Check Ok(file) => file, Err(err) => { return Err(CheckNotice::Error { - description: format!("Kann Datei nicht lesen: {}", err), + description: format!("Kann Datei nicht lesen: {err}"), line: None, }); } @@ -73,9 +73,9 @@ pub fn check_file(file: &Path, password: &str) -> Result, Check result.push(CheckNotice::Ok(format!( "Keine Probleme in '{}' erkannt", zip_file.name() - ))) + ))); } - result.append(check_result) + result.append(check_result); } Err(_) => result.push(CheckNotice::Warning { description: format!( @@ -94,7 +94,7 @@ pub fn check_file(file: &Path, password: &str) -> Result, Check zip_file.name() ), line: None, - }) + }); } } else { return Err(CheckNotice::Error { diff --git a/src/model/form.rs b/src/model/form.rs index bd01960..0261616 100644 --- a/src/model/form.rs +++ b/src/model/form.rs @@ -550,7 +550,7 @@ mod tests { assert_eq!( onkostar_editor.editor.data_form[0].entries.entry[2].default_value, "B" - ) + ); } #[test] @@ -586,7 +586,7 @@ mod tests { assert_eq!( onkostar_editor.editor.data_form[0].entries.entry[2].default_value, "" - ) + ); } #[test] @@ -883,7 +883,7 @@ mod tests { assert_eq!( onkostar_editor.editor.unterformular[0].entries.entry[1].default_value, "2024-03-18" - ) + ); } #[test] @@ -919,7 +919,7 @@ mod tests { assert_eq!( onkostar_editor.editor.unterformular[0].entries.entry[1].default_value, "" - ) + ); } #[test] diff --git a/src/profile.rs b/src/profile.rs index a95eb20..f83ab71 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -141,9 +141,9 @@ mod tests { assert_eq!(profile.forms[0].name, "DNPM Therapieplan"); assert!(profile.forms[0].menu_category.is_some()); assert_eq!(profile.forms[0].form_references.len(), 1); - assert_eq!(profile.forms[0].form_fields.len(), 1) + assert_eq!(profile.forms[0].form_fields.len(), 1); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } @@ -186,7 +186,7 @@ mod tests { Some("// Example code console.log(42);".to_string()) ); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } @@ -215,7 +215,7 @@ mod tests { true })); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } @@ -240,7 +240,7 @@ mod tests { assert_eq!(profile.forms[0].form_references[0].anzeige, None); assert_eq!(profile.forms[0].form_references[0].anzeige_auswahl, None); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } @@ -289,7 +289,7 @@ mod tests { Some("// Example code console.log(42);".to_string()) ); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } @@ -312,7 +312,7 @@ mod tests { Some("X".to_string()) ); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } @@ -336,7 +336,7 @@ mod tests { ); assert!(profile.forms[0].form_references[0].remove_filter); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } @@ -357,7 +357,7 @@ mod tests { assert_eq!(profile.forms[0].form_fields[0].name, "formularfeld_to_mod"); assert!(profile.forms[0].form_fields[0].remove_filter); } - Err(e) => panic!("Cannot deserialize profile: {}", e), + Err(e) => panic!("Cannot deserialize profile: {e}"), } } } diff --git a/src/unzip_osb.rs b/src/unzip_osb.rs index e308218..0c0f7b6 100644 --- a/src/unzip_osb.rs +++ b/src/unzip_osb.rs @@ -75,9 +75,7 @@ pub fn unzip_osb(path: &str, dir: &str, password: Option) { }; for i in 0..archive.len() { - let mut file = if let Ok(file) = archive.by_index_decrypt(i, password.as_bytes()) { - file - } else { + let Ok(mut file) = archive.by_index_decrypt(i, password.as_bytes()) else { println!( "{: <6}Abbruch! - Kann Datei nicht entpacken", style("[ERR]").red() @@ -92,10 +90,27 @@ pub fn unzip_osb(path: &str, dir: &str, password: Option) { started!(outpath.display()); - if !file.is_dir() { + if file.is_dir() { + if !outpath.exists() { + match fs::create_dir_all(&outpath) { + Ok(()) => {} + Err(err) => { + error!(outpath.display(), err); + continue; + } + } + } + ok!(outpath.display()); + } else { if let Some(p) = outpath.parent() { if !p.exists() { - fs::create_dir_all(p).unwrap(); + match fs::create_dir_all(p) { + Ok(()) => {} + Err(err) => { + error!(outpath.display(), err); + continue; + } + } } } let mut outfile = match fs::File::create(&outpath) { @@ -113,17 +128,6 @@ pub fn unzip_osb(path: &str, dir: &str, password: Option) { } } ok!(outpath.display()); - } else { - if !outpath.exists() { - match fs::create_dir_all(&outpath) { - Ok(_) => {} - Err(err) => { - error!(outpath.display(), err); - continue; - } - } - } - ok!(outpath.display()); } } }