From cf7135018623036d3d61ea5a9d9334138bfcb12c Mon Sep 17 00:00:00 2001 From: Roman Borschel <romanb@users.noreply.github.com> Date: Fri, 15 Feb 2019 09:52:35 +0100 Subject: [PATCH] Ensure config directory exists. (#1802) Ensure the config directory exists before trying to write the public key file. It is the responsibility of obtain_private_key to do so, as per the purpose of this function. --- substrate/core/network-libp2p/src/secret.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/core/network-libp2p/src/secret.rs b/substrate/core/network-libp2p/src/secret.rs index f2a501eafc2..17bd053955e 100644 --- a/substrate/core/network-libp2p/src/secret.rs +++ b/substrate/core/network-libp2p/src/secret.rs @@ -42,6 +42,7 @@ pub fn obtain_private_key( .map_err(|err| IoError::new(IoErrorKind::InvalidData, err)) } else { if let Some(ref path) = net_config_path { + fs::create_dir_all(Path::new(path))?; // Try fetch the key from a the file containing the secret. let secret_path = Path::new(path).join(SECRET_FILE); match load_private_key_from_file(&secret_path) { -- GitLab