Skip to content

Commit

Permalink
Only set executable permissions on non-Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpdp7 committed Mar 4, 2024
1 parent 063d2bf commit 22b8e91
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use starlark::starlark_simple_value;
use starlark::values::{
starlark_value, NoSerialize, ProvidesStaticType, StarlarkValue, Value, ValueLike,
};
use std::os::unix::fs::PermissionsExt;

#[derive(Debug, ProvidesStaticType, NoSerialize, Allocative)]
struct FileContents {
Expand Down Expand Up @@ -36,9 +35,14 @@ pub fn base(builder: &mut GlobalsBuilder) {
dest.push(name);
let dest = dest.as_path();
std::fs::write(dest, contents.contents.clone())?;
let mut perms = std::fs::metadata(dest).unwrap().permissions();
perms.set_mode(perms.mode() | 0o100);
std::fs::set_permissions(dest, perms).unwrap();
#[cfg(not(windows))]
{
use std::os::unix::fs::PermissionsExt;

let mut perms = std::fs::metadata(dest).unwrap().permissions();
perms.set_mode(perms.mode() | 0o100);
std::fs::set_permissions(dest, perms).unwrap();
}
Ok(0)
}

Expand Down

0 comments on commit 22b8e91

Please sign in to comment.