From bb535aec75b5a1ca361c7cf97c8d30b5f16e4f50 Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Fri, 19 Jan 2024 17:34:23 +0800 Subject: [PATCH] fix test error Signed-off-by: Alex Chi --- mini-lsm/src/lsm_storage.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mini-lsm/src/lsm_storage.rs b/mini-lsm/src/lsm_storage.rs index 1d228fd..96d7568 100644 --- a/mini-lsm/src/lsm_storage.rs +++ b/mini-lsm/src/lsm_storage.rs @@ -179,17 +179,19 @@ impl LsmStorageInner { if !path.exists() { std::fs::create_dir_all(path).context("failed to create DB dir")?; + } + let manifest_path = path.join("MANIFEST"); + if !manifest_path.exists() { if options.enable_wal { state.memtable = Arc::new(MemTable::create_with_wal( state.memtable.id(), Self::path_of_wal_static(path, state.memtable.id()), )?); } - manifest = - Manifest::create(path.join("MANIFEST")).context("failed to create manifest")?; + manifest = Manifest::create(&manifest_path).context("failed to create manifest")?; manifest.add_record_when_init(ManifestRecord::NewMemtable(state.memtable.id()))?; } else { - let (m, records) = Manifest::recover(path.join("MANIFEST"))?; + let (m, records) = Manifest::recover(&manifest_path)?; let mut memtables = BTreeSet::new(); for record in records { match record {