From ee5b934328fe8e008f219b156f0789bb89e62e10 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 19 Sep 2024 14:07:02 -0500 Subject: [PATCH] safer --- crates/libs/cppwinrt/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/libs/cppwinrt/src/lib.rs b/crates/libs/cppwinrt/src/lib.rs index 39cc01adfe..2e993dd825 100644 --- a/crates/libs/cppwinrt/src/lib.rs +++ b/crates/libs/cppwinrt/src/lib.rs @@ -14,7 +14,13 @@ where let mut path = std::env::temp_dir(); path.push(format!("cppwinrt-{VERSION}.exe")); - _ = std::fs::write(&path, std::include_bytes!("../cppwinrt.exe")); + let bytes = std::include_bytes!("../cppwinrt.exe"); + + // Concurrent builds can cause this to fail, so we just make sure the bytes match on failure. + if std::fs::write(&path, bytes).is_err() { + assert_eq!(*bytes, *std::fs::read(&path).unwrap()); + } + let mut command = std::process::Command::new(&path); command.args(args); let output = command.output().expect("failed to run cppwinrt");