From 731d13e0ba7f1521f22c179d17e71fce5fb93a52 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 1 Dec 2015 17:31:41 +0100 Subject: [PATCH] Create store path on storage backend creation --- src/main.rs | 9 +++++++-- src/storage/backend.rs | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 02e9d34c..62834703 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,8 @@ mod module; mod storage; mod ui; +use std::process::exit; + fn main() { let yaml = load_yaml!("../etc/cli.yml"); let app = App::from_yaml(yaml); @@ -41,14 +43,17 @@ fn main() { debug!("Runtime : {:?}", &rt); + let backend = StorageBackend::new(&rt).unwrap_or_else(|e| { + error!("Error: {}", e); + exit(1); + }); + if let Some(matches) = rt.config.cli_matches.subcommand_matches("bm") { let module = BMModule::new(&rt); let commands = module.get_commands(&rt); if let Some(command) = matches.subcommand_name() { debug!("Subcommand: {}", command); - let backend = StorageBackend::new(&rt); - let cmdenv = CommandEnv { rt: &rt, bk: &backend, diff --git a/src/storage/backend.rs b/src/storage/backend.rs index 42f734c0..d4e6c61c 100644 --- a/src/storage/backend.rs +++ b/src/storage/backend.rs @@ -6,6 +6,7 @@ use std::path::Path; use std::path::PathBuf; use std::vec::Vec; use std::fs::File as FSFile; +use std::fs::create_dir_all; use std::fs::remove_file; use std::io::Read; use std::io::Write;