|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
use color_eyre::eyre::{Result, WrapErr}; |
|
|
|
|
use rocksdb::{Options, DB}; |
|
|
|
|
use std::path::Path; |
|
|
|
|
use tracing::info; |
|
|
|
|
|
|
|
|
|
/// Shared functionality surrounding use of rocksdb
|
|
|
|
|
pub mod persistence; |
|
|
|
@ -14,6 +15,14 @@ pub fn from_path(db_path: &str) -> Result<DB> { |
|
|
|
|
let mut path = Path::new(".").canonicalize()?; |
|
|
|
|
path.extend(&[db_path]); |
|
|
|
|
|
|
|
|
|
match path.is_dir() { |
|
|
|
|
true => info!( |
|
|
|
|
"Opening existing db at {path}", |
|
|
|
|
path = path.to_str().unwrap() |
|
|
|
|
), |
|
|
|
|
false => info!("Creating db a {path}", path = path.to_str().unwrap()), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let mut opts = Options::default(); |
|
|
|
|
opts.create_if_missing(true); |
|
|
|
|
|
|
|
|
|