fixup! Rework database fallback

This commit is contained in:
Cole Helbling 2020-03-29 13:29:05 -07:00
parent e479baac3b
commit d54ae15d41
No known key found for this signature in database
GPG Key ID: B37E0F2371016A4C
1 changed files with 9 additions and 7 deletions

View File

@ -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> {