Add Store::ensure_store_path_exists()
This commit is contained in:
parent
c97f4bab56
commit
d20ace3e80
1 changed files with 14 additions and 0 deletions
|
@ -133,6 +133,8 @@ impl Store {
|
|||
format!("{}/{}-{}.imag", self.storepath, file.owning_module_name, ids)
|
||||
};
|
||||
|
||||
self.ensure_store_path_exists();
|
||||
|
||||
FSFile::create(&path).map(|mut fsfile| {
|
||||
fsfile.write_all(&text.unwrap().clone().into_bytes()[..])
|
||||
}).map_err(|writeerr| {
|
||||
|
@ -140,6 +142,18 @@ impl Store {
|
|||
}).and(Ok(true)).unwrap()
|
||||
}
|
||||
|
||||
fn ensure_store_path_exists(&self) {
|
||||
use std::fs::create_dir_all;
|
||||
use std::process::exit;
|
||||
|
||||
create_dir_all(&self.storepath).unwrap_or_else(|e| {
|
||||
error!("Could not create store: '{}'", self.storepath);
|
||||
error!("Error : '{}'", e);
|
||||
error!("Killing myself now");
|
||||
exit(1);
|
||||
})
|
||||
}
|
||||
|
||||
pub fn load(&self, id: &FileID) -> Option<Rc<RefCell<File>>> {
|
||||
debug!("Loading '{:?}'", id);
|
||||
self.cache.borrow().get(id).cloned()
|
||||
|
|
Loading…
Reference in a new issue