Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime/fs): preserve permissions in copyFileSync for macOS #17412

Merged
merged 2 commits into from
Jan 14, 2023

Conversation

littledivy
Copy link
Member

Fixes #16921

Comment on lines +914 to +930
let perm = from_file.metadata().map_err(err_mapper)?.permissions();

let mut to_file = std::fs::OpenOptions::new()
// create the file with the correct mode right away
.mode(perm.mode())
.write(true)
.create(true)
.truncate(true)
.open(&to_path)
.map_err(err_mapper)?;
let writer_metadata = to_file.metadata()?;
if writer_metadata.is_file() {
// Set the correct file permissions, in case the file already existed.
// Don't set the permissions on already existing non-files like
// pipes/FIFOs or device nodes.
to_file.set_permissions(perm)?;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@littledivy littledivy marked this pull request as ready for review January 14, 2023 09:36
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@littledivy littledivy enabled auto-merge (squash) January 14, 2023 13:40
@littledivy littledivy merged commit ae2981d into denoland:main Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deno.copyFileSync not preserving permissions on MacOS
2 participants