From 92d77f9ec373261d91a65e68c95baaaa9fc9b95e Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Mon, 14 Jul 2025 23:30:37 +0200 Subject: [PATCH] crypto/ssh/keystore: Reduce scope of DirBuilderExt Directory builder extensions are platform specific and only available on Unix. Move their use into a conditionally compiled block, so that we can build on Windows. --- crates/radicle-crypto/src/ssh/keystore.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/radicle-crypto/src/ssh/keystore.rs b/crates/radicle-crypto/src/ssh/keystore.rs index ab5f2d1a..75e26b65 100644 --- a/crates/radicle-crypto/src/ssh/keystore.rs +++ b/crates/radicle-crypto/src/ssh/keystore.rs @@ -1,5 +1,4 @@ use std::ops::Deref; -use std::os::unix::fs::DirBuilderExt; use std::path::{Path, PathBuf}; use std::{fs, io}; @@ -94,10 +93,18 @@ impl Keystore { return Err(Error::AlreadyInitialized); } - fs::DirBuilder::new() - .recursive(true) - .mode(0o700) - .create(&self.path)?; + { + let mut builder = fs::DirBuilder::new(); + builder.recursive(true); + + #[cfg(unix)] + { + use std::os::unix::fs::DirBuilderExt as _; + builder.mode(0o700); + } + + builder.create(&self.path)?; + } secret.write_openssh_file(&path, ssh_key::LineEnding::default())?; public.write_openssh_file(&path.with_extension("pub"))?;