fix not waiting for folder creation

This commit is contained in:
leca 2024-04-05 19:32:10 +03:00
parent f4cc2f492c
commit 749e38d5e5
1 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,7 @@ pub fn init() {
let mut appdata = PathBuf::from(&binding);
appdata = appdata.join("learn-hieroglyph");
Command::new("mkdir").arg(&appdata);
Command::new("mkdir").arg(&appdata).spawn().expect(&format!("Cannot create program's home: {}", &appdata.to_str().unwrap())).wait().unwrap();
appdata
} else {
@ -18,16 +18,17 @@ pub fn init() {
let mut home = PathBuf::from(&binding);
home = home.join(".config/learn-hieroglyph");
Command::new("mkdir").args(["-p", &home.to_str().unwrap()]).spawn().expect(&format!("Cannot create program's home: {}", &home.to_str().unwrap()));
Command::new("mkdir").args(["-p", &home.to_str().unwrap()]).spawn().expect(&format!("Cannot create program's home: {}", &home.to_str().unwrap())).wait().unwrap();
home
};
let mut p = PROGRAM_HOME_PATH.write().unwrap();
*p = program_home_path.as_path().to_str().unwrap().to_string();
println!("Program's home: {}", program_home_path.as_path().to_str().unwrap());
let db_path = program_home_path.join("db.sqlite");
let connection = Connection::open(program_home_path.join("db.sqlite")).unwrap();
let connection = Connection::open(db_path).unwrap();
connection.execute("CREATE TABLE IF NOT EXISTS cards (
id INTEGER PRIMARY KEY AUTOINCREMENT,