mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-19 11:46:50 +00:00
chore: code cleanup
This commit is contained in:
parent
ea47b101f2
commit
b055146c8f
@ -32,7 +32,7 @@ pub fn check_file(file: &Path, password: &str) -> Result<Vec<CheckNotice>, 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<Vec<CheckNotice>, 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<Vec<CheckNotice>, 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<Vec<CheckNotice>, Check
|
||||
zip_file.name()
|
||||
),
|
||||
line: None,
|
||||
})
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return Err(CheckNotice::Error {
|
||||
|
@ -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]
|
||||
|
@ -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}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,9 +75,7 @@ pub fn unzip_osb(path: &str, dir: &str, password: Option<String>) {
|
||||
};
|
||||
|
||||
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<String>) {
|
||||
|
||||
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<String>) {
|
||||
}
|
||||
}
|
||||
ok!(outpath.display());
|
||||
} else {
|
||||
if !outpath.exists() {
|
||||
match fs::create_dir_all(&outpath) {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
error!(outpath.display(), err);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
ok!(outpath.display());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user