-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 #20925, cp not preserving permissions #27295
Conversation
@vtjnash reading your comment, it appears you were asking for a +"""
+ sendfile(src, dst; mode = nothing)
+
+Copy file `src` to path `dst`, creating `dst` with the given `mode`. If `mode`
+is left at the default value of `nothing`, the mode of the `src` file is used.
+"""
+function sendfile(src::AbstractString, dst::AbstractString;
+ mode::Union{Unsigned,Nothing}=nothing)
src_open = false
dst_open = false
local src_file, dst_file
try
src_file = open(src, JL_O_RDONLY)
src_open = true
- dst_file = open(dst, JL_O_CREAT | JL_O_TRUNC | JL_O_WRONLY, filemode(src_file))
+ if mode == nothing
+ mode = filemode(src_file)
+ end
+ dst_file = open(dst, JL_O_CREAT | JL_O_TRUNC | JL_O_WRONLY, mode)
dst_open = true To be honest, I don't see why you would want to do this. For this to be useful, we would then add on |
Mainly that |
Great. Then I'll assume this is an easy review for you and request one. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a safe enough change. In the future, we may even want to use the new, high-performance, libuv wrapper uv_fs_copyfile
Great, will merge once it's green then. |
Refs nodejs/node#15394 |
https://travis-ci.org/JuliaLang/julia/jobs/384922807
|
Thanks Kristoffer, I've added umask-aware tests. |
Windows failures unrelated, and we passed the |
Rebasing @tkelman's branch here, as I can confirm that it fixes #26907 (comment)