fixup! Rework database fallback
This commit is contained in:
parent
e479baac3b
commit
d54ae15d41
16
src/util.rs
16
src/util.rs
|
|
@ -22,19 +22,21 @@ pub fn path_to_bytes<P: AsRef<Path>>(path: &P) -> Option<&[u8]> {
|
|||
}
|
||||
|
||||
pub fn get_db() -> Result<DB> {
|
||||
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<Epoch> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue