This commit is contained in:
parent
4d0cc7a6f1
commit
1b947ec188
|
@ -177,9 +177,8 @@ fn find_available_backup_dir() -> PathBuf {
|
|||
"".to_string()
|
||||
};
|
||||
|
||||
let target_backup_dir = dirs::document_dir()
|
||||
.expect("unable to generate backup directory")
|
||||
.join(format!("espanso-migrate-backup{}", num));
|
||||
let target_backup_dir =
|
||||
find_backup_dir_location().join(format!("espanso-migrate-backup{}", num));
|
||||
|
||||
if !target_backup_dir.is_dir() {
|
||||
return target_backup_dir;
|
||||
|
@ -189,6 +188,22 @@ fn find_available_backup_dir() -> PathBuf {
|
|||
panic!("could not generate valid backup directory");
|
||||
}
|
||||
|
||||
fn find_backup_dir_location() -> PathBuf {
|
||||
if let Some(documents_dir) = dirs::document_dir() {
|
||||
return documents_dir;
|
||||
}
|
||||
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
return home_dir;
|
||||
}
|
||||
|
||||
if let Ok(current_dir) = std::env::current_dir() {
|
||||
return current_dir;
|
||||
}
|
||||
|
||||
panic!("unable to generate suitable backup location directory");
|
||||
}
|
||||
|
||||
fn error_print_and_log(msg: &str) {
|
||||
error!("{}", msg);
|
||||
eprintln!("{}", msg);
|
||||
|
|
Loading…
Reference in New Issue
Block a user