Skip to content

Commit

Permalink
Revert "Windows file modes: turn executable bits off for plain fails (J…
Browse files Browse the repository at this point in the history
…uliaIO#83)"

This reverts commit 1b63f2a.
  • Loading branch information
KristofferC committed Dec 5, 2020
1 parent 19293c2 commit 5075a37
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 164 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ ArgTools = "1.1"
julia = "1.3"

[extras]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SimpleBufferStream = "777ac1f9-54b0-4bf8-805c-2214025038e7"
Tar_jll = "9b64493d-8859-5bf3-93d7-7c32dd38186f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Random", "Tar_jll", "Test", "SimpleBufferStream"]
test = ["Pkg", "Random", "Tar_jll", "Test", "SimpleBufferStream"]
29 changes: 5 additions & 24 deletions src/extract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,12 @@ function extract_tarball(
copy_symlinks || symlink(hdr.link, sys_path)
elseif hdr.type == :file
read_data(tar, sys_path, size=hdr.size, buf=buf)
# change executable bit if necessary
if Sys.iswindows() !iszero(0o100 & hdr.mode)
# set executable bit if necessary
if !iszero(hdr.mode & 0o100)
mode = filemode(sys_path)
if Sys.iswindows()
# turn off all execute bits
mode &= 0o666
else
# copy read bits to execute bits with
# at least the user execute bit on
mode |= 0o100 | (mode & 0o444) >> 2
end
chmod(sys_path, mode)
# exec bits = read bits, but set user read at least:
chmod(sys_path, mode | ((mode & 0o444) >> 2) | 0o100)
# TODO: use actual umask exec bits instead?
end
else # should already be caught by check_header
error("unsupported tarball entry type: $(hdr.type)")
Expand Down Expand Up @@ -132,19 +126,6 @@ function extract_tarball(
src = reduce(joinpath, init=root, split(what, '/'))
dst = reduce(joinpath, init=root, split(path, '/'))
cp(src, dst)
if Sys.iswindows()
# our `cp` doesn't copy ACL properties, so manually set them via `chmod`
function copy_mode(src::String, dst::String)
chmod(dst, filemode(src))
isdir(dst) || return
for name in readdir(dst)
sub_src = joinpath(src, name)
sub_dst = joinpath(dst, name)
copy_mode(sub_src, sub_dst)
end
end
copy_mode(src, dst)
end
end
end
end
Expand Down
8 changes: 1 addition & 7 deletions src/header.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,7 @@ function path_header(sys_path::AbstractString, tar_path::AbstractString)
elseif isfile(st)
size = filesize(st)
type = :file
# Windows can't re-use the `lstat` result, we need to ask
# the system whether it's executable or not via `access()`
if Sys.iswindows()
mode = Sys.isexecutable(sys_path) ? 0o755 : 0o644
else
mode = iszero(filemode(st) & 0o100) ? 0o644 : 0o755
end
mode = iszero(filemode(st) & 0o100) ? 0o644 : 0o755
link = ""
else
error("unsupported file type: $(repr(sys_path))")
Expand Down
130 changes: 0 additions & 130 deletions test/git_tools.jl

This file was deleted.

3 changes: 1 addition & 2 deletions test/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ using Random
using ArgTools

import Tar

include("git_tools.jl")
import Pkg.GitTools

const NON_STDLIB_TESTS = Main == @__MODULE__

Expand Down

0 comments on commit 5075a37

Please sign in to comment.