From 82060b61f91dab756977d83665c9536ce13f3f5d Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sat, 15 Oct 2022 20:29:57 -0700 Subject: [PATCH] Use redb's two-phase write strategy in production --- src/index.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.rs b/src/index.rs index 69884afe32..342c85c035 100644 --- a/src/index.rs +++ b/src/index.rs @@ -124,7 +124,11 @@ impl Index { Ok(database) => database, Err(redb::Error::Io(error)) if error.kind() == io::ErrorKind::NotFound => unsafe { Database::builder() - .set_write_strategy(WriteStrategy::Checksum) + .set_write_strategy(if cfg!(test) { + WriteStrategy::Checksum + } else { + WriteStrategy::TwoPhase + }) .create(&database_path, options.max_index_size().0)? }, Err(error) => return Err(error.into()),