...
This commit is contained in:
@@ -43,6 +43,8 @@ pub struct OurDBConfig {
|
||||
/// - 4: For databases with < 4,294,967,296 records (single file)
|
||||
/// - 6: For large databases requiring multiple files (default)
|
||||
pub keysize: Option<u8>,
|
||||
/// Whether to reset the database if it exists (default: false)
|
||||
pub reset: Option<bool>,
|
||||
}
|
||||
|
||||
/// Arguments for setting a value in OurDB
|
||||
@@ -56,6 +58,11 @@ pub struct OurDBSetArgs<'a> {
|
||||
impl OurDB {
|
||||
/// Creates a new OurDB instance with the given configuration
|
||||
pub fn new(config: OurDBConfig) -> Result<Self, Error> {
|
||||
// If reset is true and the path exists, remove it first
|
||||
if config.reset.unwrap_or(false) && config.path.exists() {
|
||||
std::fs::remove_dir_all(&config.path)?;
|
||||
}
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
std::fs::create_dir_all(&config.path)?;
|
||||
|
||||
|
Reference in New Issue
Block a user