Store::new(): Create path if nonexistent

This commit is contained in:
Matthias Beyer 2016-01-17 17:42:40 +01:00
parent b44fd9fec0
commit 4f71563eb4

View file

@ -55,6 +55,14 @@ impl Store {
/// Create a new Store object
pub fn new(location: PathBuf) -> Store {
use std::fs::create_dir_all;
if !location.exists() {
create_dir_all(location.clone()).ok(); // TODO: Error handling?
}
// TODO: Path exists, but is a file? What now?
Store {
location: location,
entries: Arc::new(RwLock::new(HashMap::new())),