nested if statements in command.rs could be made more concise
hunterchen7 opened this issue · 1 comments
hunterchen7 commented
These nested if
statements from src-tauri/src/command.rs
can be made more concise:
This one from delete_library_folder()
:
if folder_path_buf.exists() {
if folder_path_buf.is_dir() {
match fs::remove_dir_all(&folder_path_buf) {
Ok(_) => {},
Err(e) => eprintln!("Error removing folder {}: {:?}", folder_id, e),
}
}
}
can be replaced with:
if folder_path_buf.exists() && folder_path_buf.is_dir() {
match fs::remove_dir_all(&folder_path_buf) {
Ok(_) => {},
Err(e) => eprintln!("Error removing folder {}: {:?}", folder_id, e),
}
}
and this one from delete_library_paper()
:
if paper_filepath_buf.exists() {
if paper_filepath_buf.is_file() {
match fs::remove_file(&paper_filepath_buf) {
Ok(_) => {},
Err(e) => eprintln!("Error removing folder {}: {:?}", folder_id, e),
}
}
}
with:
if paper_filepath_buf.exists() && paper_filepath_buf.is_file() {
match fs::remove_file(&paper_filepath_buf) {
Ok(_) => {},
Err(e) => eprintln!("Error removing folder {}: {:?}", folder_id, e),
}
}
hunterchen7 commented
resolved with PR #70