Repository: qdrant/qdrant
File: lib/edge/src/lib.rs (Rust)

Code before:
use shard::operations::CollectionUpdateOperations;
use shard::search::CoreSearchRequest;
use shard::search_result_aggregator::BatchResultAggregator;
use shard::segment_holder::{LockedSegmentHolder, SegmentHolder};
use shard::update::*;
use shard::wal::SerdeWal;
use wal::WalOptions;

#[derive(Debug)]
pub struct Shard {
    _path: PathBuf,
    config: SegmentConfig,
    wal: Mutex<SerdeWal<CollectionUpdateOperations>>,
    segments: LockedSegmentHolder,
}

const WAL_PATH: &str = "wal";
const SEGMENTS_PATH: &str = "segments";

impl Shard {
    pub fn load(path: &Path, mut config: Option<SegmentConfig>) -> OperationResult<Self> {
        let wal_path = path.join(WAL_PATH);

        if !wal_path.exists() {
            fs::create_dir(&wal_path).map_err(|err| {
                OperationError::service_error(format!("failed to create WAL directory: {err}",))
            })?;
        }

        let wal: SerdeWal<CollectionUpdateOperations> =
            SerdeWal::new(&wal_path, default_wal_options()).map_err(|err| {
                OperationError::service_error(format!(
                    "failed to open WAL {}: {err}",
                    wal_path.display(),
                ))
            })?;

        let segments_path = path.join(SEGMENTS_PATH);

        if !segments_path.exists() {
            fs::create_dir(&segments_path).map_err(|err| {
                OperationError::service_error(format!("failed to create segments directory: {err}"))
            })?;
        }

        let segments_dir = fs::read_dir(&segments_path).map_err(|err| {
            OperationError::service_error(format!("failed to read segments directory: {err}",))
        })?;

        let mut segments = SegmentHolder::default();


Review comment (bug):
Nit:

```suggestion
                OperationError::service_error(format!("failed to create WAL directory: {err}"))
```

Code after:
use shard::operations::CollectionUpdateOperations;
use shard::search::CoreSearchRequest;
use shard::search_result_aggregator::BatchResultAggregator;
use shard::segment_holder::{LockedSegmentHolder, SegmentHolder};
use shard::update::*;
use shard::wal::SerdeWal;
use wal::WalOptions;

#[derive(Debug)]
pub struct Shard {
    _path: PathBuf,
    config: SegmentConfig,
    wal: Mutex<SerdeWal<CollectionUpdateOperations>>,
    segments: LockedSegmentHolder,
}

const WAL_PATH: &str = "wal";
const SEGMENTS_PATH: &str = "segments";

impl Shard {
    pub fn load(path: &Path, mut config: Option<SegmentConfig>) -> OperationResult<Self> {
        let wal_path = path.join(WAL_PATH);

        if !wal_path.exists() {
            fs::create_dir(&wal_path).map_err(|err| {
                OperationError::service_error(format!("failed to create WAL directory: {err}"))
            })?;
        }

        let wal: SerdeWal<CollectionUpdateOperations> =
            SerdeWal::new(&wal_path, default_wal_options()).map_err(|err| {
                OperationError::service_error(format!(
                    "failed to open WAL {}: {err}",
                    wal_path.display(),
                ))
            })?;

        let segments_path = path.join(SEGMENTS_PATH);

        if !segments_path.exists() {
            fs::create_dir(&segments_path).map_err(|err| {
                OperationError::service_error(format!("failed to create segments directory: {err}"))
            })?;
        }

        let segments_dir = fs::read_dir(&segments_path).map_err(|err| {
            OperationError::service_error(format!("failed to read segments directory: {err}"))
        })?;

        let mut segments = SegmentHolder::default();