From c076c5d47c580f9138ae135a377926a1fae2cb13 Mon Sep 17 00:00:00 2001 From: marvin-j97 Date: Fri, 17 May 2024 19:08:48 +0200 Subject: [PATCH] fix(ci): recreate segments folder if missing --- Cargo.toml | 2 +- src/tree.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9dcdb34..a94efe9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "lsm-tree" description = "A K.I.S.S. implementation of log-structured merge trees (LSM-trees/LSMTs)" license = "MIT OR Apache-2.0" -version = "1.0.0" +version = "1.0.1" edition = "2021" rust-version = "1.74.0" readme = "README.md" diff --git a/src/tree.rs b/src/tree.rs index 989cab4..0b16704 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -2,6 +2,7 @@ use crate::{ compaction::CompactionStrategy, config::{Config, PersistedConfig}, descriptor_table::FileDescriptorTable, + file::fsync_directory, levels::LevelManifest, memtable::MemTable, range::{MemtableLockGuard, TreeIter}, @@ -938,7 +939,14 @@ impl Tree { let mut segments = vec![]; - for dirent in std::fs::read_dir(tree_path.join(SEGMENTS_FOLDER))? { + let segment_base_folder = tree_path.join(SEGMENTS_FOLDER); + + if !segment_base_folder.try_exists()? { + std::fs::create_dir_all(&segment_base_folder)?; + fsync_directory(&segment_base_folder)?; + } + + for dirent in std::fs::read_dir(&segment_base_folder)? { let dirent = dirent?; let file_name = dirent.file_name();