Skip to content

Commit

Permalink
fix: use unsafe block in opening env
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Jul 14, 2024
1 parent c19f718 commit b288413
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ pub fn new_env() -> Result<heed::Env> {
let path = glib::user_data_dir().join("mousai/db");
fs::create_dir_all(&path)
.with_context(|| format!("Failed to create db dir at {}", path.display()))?;
let env = heed::EnvOpenOptions::new()
.map_size(100 * 1024 * 1024) // 100 MiB
.max_dbs(N_NAMED_DBS)
.open(&path)
.with_context(|| format!("Failed to open heed env at {}", path.display()))?;
let env = unsafe {
heed::EnvOpenOptions::new()
.map_size(100 * 1024 * 1024) // 100 MiB
.max_dbs(N_NAMED_DBS)
.open(&path)
.with_context(|| format!("Failed to open heed env at {}", path.display()))?
};

tracing::debug!(
?path,
Expand All @@ -43,11 +45,13 @@ pub fn new_env() -> Result<heed::Env> {
#[cfg(test)]
pub fn new_test_env() -> (heed::Env, tempfile::TempDir) {
let tempdir = tempfile::tempdir().unwrap();
let env = heed::EnvOpenOptions::new()
.map_size(100 * 1024 * 1024) // 100 MiB
.max_dbs(1)
.open(&tempdir)
.unwrap();
let env = unsafe {
heed::EnvOpenOptions::new()
.map_size(100 * 1024 * 1024) // 100 MiB
.max_dbs(1)
.open(&tempdir)
.unwrap()
};
(env, tempdir)
}

Expand Down

0 comments on commit b288413

Please sign in to comment.