diff --git a/src/util.rs b/src/util.rs index 3df7eac..80dcccd 100644 --- a/src/util.rs +++ b/src/util.rs @@ -22,19 +22,21 @@ pub fn path_to_bytes>(path: &P) -> Option<&[u8]> { } pub fn get_db() -> Result { - let mut db_file = config::zo_data_dir()?; - db_file.push("db.zo"); + let mut db_path = config::zo_data_dir()?; + db_path.push("db.zo"); // FIXME: fallback to old database location; remove in next breaking version - if let Some(mut old_db) = dirs::home_dir() { - old_db.push(".zo"); + if !db_path.is_file() { + if let Some(mut old_db_path) = dirs::home_dir() { + old_db_path.push(".zo"); - if old_db.is_file() && !db_file.is_file() { - return DB::open_and_migrate(old_db, db_file); + if old_db_path.is_file() { + return DB::open_and_migrate(old_db_path, db_path); + } } } - DB::open(db_file) + DB::open(db_path) } pub fn get_current_time() -> Result {