|
|
|
@ -5,14 +5,14 @@ use std::path::{PathBuf, Path}; |
|
|
|
|
|
|
|
|
|
use rocksdb::{DB, Options}; |
|
|
|
|
|
|
|
|
|
// Ensures that DB::Destroy is called for this database when DBPath is dropped.
|
|
|
|
|
/// Ensures that DB::Destroy is called for this database when DBPath is dropped.
|
|
|
|
|
pub struct DBPath { |
|
|
|
|
path: PathBuf |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl DBPath { |
|
|
|
|
// Suffixes the given `prefix` with a timestamp to ensure that subsequent test runs don't reuse
|
|
|
|
|
// an old database in case of panics prior to Drop being called.
|
|
|
|
|
/// Suffixes the given `prefix` with a timestamp to ensure that subsequent test runs don't reuse
|
|
|
|
|
/// an old database in case of panics prior to Drop being called.
|
|
|
|
|
pub fn new(prefix: &str) -> DBPath { |
|
|
|
|
let current_time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); |
|
|
|
|
let path = format!( |
|
|
|
|