diff --git a/sn_protocol/src/node_registry.rs b/sn_protocol/src/node_registry.rs index 9f0f26a97e..4b58c97ea8 100644 --- a/sn_protocol/src/node_registry.rs +++ b/sn_protocol/src/node_registry.rs @@ -139,6 +139,11 @@ pub struct NodeRegistry { impl NodeRegistry { pub fn save(&self) -> Result<()> { + let path = Path::new(&self.save_path); + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent)?; + } + let json = serde_json::to_string(self)?; let mut file = std::fs::File::create(self.save_path.clone())?; file.write_all(json.as_bytes())?;