From 05f535dfedb1ad5a2787e416fa6e064054202cec Mon Sep 17 00:00:00 2001 From: Andrea Campi Date: Mon, 13 Jan 2025 04:27:43 -0800 Subject: [PATCH] Fix a Unix dependency Summary: D67803881 tried to preserve non-Unix support while making changes, but changed a compile-time check into a runtime one; and that's now failing the MSDK build. Reviewed By: RajivTS Differential Revision: D68094673 fbshipit-source-id: ef4a7c656650e7f473950473ea67f7565932b090 --- .../scs/client/src/commands/export.rs | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/eden/mononoke/scs/client/src/commands/export.rs b/eden/mononoke/scs/client/src/commands/export.rs index ad77bb8cdf2a1..92019abda3017 100644 --- a/eden/mononoke/scs/client/src/commands/export.rs +++ b/eden/mononoke/scs/client/src/commands/export.rs @@ -669,7 +669,9 @@ async fn filesystem_writer<'a, 'b>( // Kick off the next write { cloned!(file_metadata); - if file_metadata.entry_type == thrift::EntryType::LINK && cfg!(unix) { + + #[cfg(unix)] + if file_metadata.entry_type == thrift::EntryType::LINK { use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; let fut = Box::new(tokio::spawn(async move { @@ -680,28 +682,30 @@ async fn filesystem_writer<'a, 'b>( Ok(()) })); file_writes_tx.send(fut).await?; - } else { - let out_file = tokio::fs::File::create(&file_metadata.path).await?; - // Create a buffered writer for the file - let mut writer = BufWriter::new(out_file); - let fut = Box::new(tokio::spawn(async move { - while let Some(chunk) = chunks_rx.recv().await { - writer.write_all(&chunk).await?; - } - writer.flush().await?; - Ok(()) - })); - file_writes_tx.send(fut).await?; - #[cfg(unix)] - if file_metadata.entry_type == thrift::EntryType::EXEC { - use std::os::unix::fs::PermissionsExt; - let out_file = tokio::fs::File::open(&file_metadata.path).await?; - let mut permissions = out_file.metadata().await?.permissions(); - let mode = permissions.mode(); - // Propagate read permissions to execute permissions. - permissions.set_mode(mode | ((mode & 0o444) >> 2)); - tokio::fs::set_permissions(file_metadata.path, permissions).await? + continue; + } + + let out_file = tokio::fs::File::create(&file_metadata.path).await?; + // Create a buffered writer for the file + let mut writer = BufWriter::new(out_file); + let fut = Box::new(tokio::spawn(async move { + while let Some(chunk) = chunks_rx.recv().await { + writer.write_all(&chunk).await?; } + writer.flush().await?; + Ok(()) + })); + file_writes_tx.send(fut).await?; + + #[cfg(unix)] + if file_metadata.entry_type == thrift::EntryType::EXEC { + use std::os::unix::fs::PermissionsExt; + let out_file = tokio::fs::File::open(&file_metadata.path).await?; + let mut permissions = out_file.metadata().await?.permissions(); + let mode = permissions.mode(); + // Propagate read permissions to execute permissions. + permissions.set_mode(mode | ((mode & 0o444) >> 2)); + tokio::fs::set_permissions(file_metadata.path, permissions).await? } } }