diff --git a/mdb_shard/src/shard_file_manager.rs b/mdb_shard/src/shard_file_manager.rs index f837a58..ad1afa3 100644 --- a/mdb_shard/src/shard_file_manager.rs +++ b/mdb_shard/src/shard_file_manager.rs @@ -178,6 +178,11 @@ impl ShardFileManager { async fn new_from_builder(sbp: ShardFileManagerOptions) -> Result> { let shard_directory = std::path::absolute(sbp.shard_directory)?; + // Make sure the shard directory exists; create it if not. + if !shard_directory.exists() { + std::fs::create_dir_all(&shard_directory)?; + } + // Clean up old shards if needed if sbp.clean_expired_shards { MDBShardFile::clean_expired_shards(&shard_directory, sbp.shard_expiration_delete_buffer_secs)?;