From c9e6850312ce5017ad4fd919406f8562890c6186 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Mon, 6 Nov 2023 11:52:49 +0800 Subject: [PATCH] apple-codesign: avoid expect() when checking for parent directory This is cleaner. --- apple-codesign/src/bundle_signing.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apple-codesign/src/bundle_signing.rs b/apple-codesign/src/bundle_signing.rs index e0851439e..e1020f43b 100644 --- a/apple-codesign/src/bundle_signing.rs +++ b/apple-codesign/src/bundle_signing.rs @@ -303,11 +303,9 @@ impl<'a, 'key> BundleFileHandler for SingleBundleHandler<'a, 'key> { let dest_path = self.dest_dir.join(dest_rel_path); if source_path != dest_path { - std::fs::create_dir_all( - dest_path - .parent() - .expect("parent directory should be available"), - )?; + if let Some(parent) = dest_path.parent() { + std::fs::create_dir_all(parent)?; + } let metadata = source_path.symlink_metadata()?; let mtime = filetime::FileTime::from_last_modification_time(&metadata);