Skip to content

Commit

Permalink
Fix a Unix dependency
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andreacampi authored and facebook-github-bot committed Jan 13, 2025
1 parent 242dc5b commit 05f535d
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions eden/mononoke/scs/client/src/commands/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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?
}
}
}
Expand Down

0 comments on commit 05f535d

Please sign in to comment.