mirror of
https://git.deuxfleurs.fr/Deuxfleurs/garage.git
synced 2024-11-21 23:51:00 +00:00
Ensure data dir is created immediately when Garage starts (fix #349)
This commit is contained in:
parent
11bdc971e2
commit
07febd3ecd
1 changed files with 7 additions and 2 deletions
|
@ -6,7 +6,7 @@ use garage_db as db;
|
||||||
|
|
||||||
use garage_util::background::*;
|
use garage_util::background::*;
|
||||||
use garage_util::config::*;
|
use garage_util::config::*;
|
||||||
use garage_util::error::Error;
|
use garage_util::error::*;
|
||||||
|
|
||||||
use garage_rpc::system::System;
|
use garage_rpc::system::System;
|
||||||
|
|
||||||
|
@ -76,9 +76,14 @@ pub struct GarageK2V {
|
||||||
impl Garage {
|
impl Garage {
|
||||||
/// Create and run garage
|
/// Create and run garage
|
||||||
pub fn new(config: Config, background: Arc<BackgroundRunner>) -> Result<Arc<Self>, Error> {
|
pub fn new(config: Config, background: Arc<BackgroundRunner>) -> Result<Arc<Self>, Error> {
|
||||||
|
// Create meta dir and data dir if they don't exist already
|
||||||
|
std::fs::create_dir_all(&config.metadata_dir)
|
||||||
|
.ok_or_message("Unable to create Garage metadata directory")?;
|
||||||
|
std::fs::create_dir_all(&config.data_dir)
|
||||||
|
.ok_or_message("Unable to create Garage data directory")?;
|
||||||
|
|
||||||
info!("Opening database...");
|
info!("Opening database...");
|
||||||
let mut db_path = config.metadata_dir.clone();
|
let mut db_path = config.metadata_dir.clone();
|
||||||
std::fs::create_dir_all(&db_path).expect("Unable to create Garage meta data directory");
|
|
||||||
let db = match config.db_engine.as_str() {
|
let db = match config.db_engine.as_str() {
|
||||||
// ---- Sled DB ----
|
// ---- Sled DB ----
|
||||||
#[cfg(feature = "sled")]
|
#[cfg(feature = "sled")]
|
||||||
|
|
Loading…
Reference in a new issue