Ensuring the whole path to pem files exist before saving

This commit is contained in:
Jedrzej Stuczynski
2020-01-31 10:03:51 +00:00
parent 2ac707d57c
commit bb29421854
+4
View File
@@ -86,6 +86,10 @@ impl PemStore {
}
fn write_pem_file(&self, filepath: PathBuf, data: Vec<u8>, tag: String) -> io::Result<()> {
// ensure the whole directory structure exists
if let Some(parent_dir) = filepath.parent() {
std::fs::create_dir_all(parent_dir)?;
}
let pem = Pem {
tag,
contents: data,