JuliaIO / Tar.jl

TAR files: create, list, extract them in pure Julia
MIT License
79 stars 19 forks source link

Win10: extracted files require admin rights to delete the file #96

Open jdonnerstag opened 3 years ago

jdonnerstag commented 3 years ago

Hi,

I have gow (https://github.com/bmatzelle/gow - Gnu on Windows) installed on my win10 laptop to leverage most of the (linux) gnu utils on the cmd commandline. I used tar -czvf data.tar.gz test*.* to create a small archiv with 3 files. tar -tzvf ... gives the following output:

C:\source_code\julia\...\archives>tar -tzvf data.tar.gz
-rw-rw-rw-  0 0      0         475 Nov 05 19:17 ./test_1.dat
-rw-rw-rw-  0 0      0         155 Nov 05 19:17 ./test_2.dat
-rw-rw-rw-  0 0      0         156 Nov 05 19:17 ./test_3.dat

I can export it like this:

function untar(data::IO, exdir::String)
    if isdir(exdir) == false mkdir(exdir) end
    tar = GzipDecompressorStream(data)
    Tar.extract(tar, exdir; copy_symlinks=true)
    close(tar)
end

and the files are created with the correct content. But in order to delete the files again, I need windows admin rights. And the julia traceback when trying to delete the file is

Got exception outside of a @test
  IOError: unlink: permission denied (EACCES)
  Stacktrace:
   [1] uv_error at .\libuv.jl:97 [inlined]
   [2] unlink(::String) at .\file.jl:918
   [3] rm(::String; force::Bool, recursive::Bool) at .\file.jl:268
   [4] rm(::String; force::Bool, recursive::Bool) at .\file.jl:278

Looking at the windows file properties, "Read", "Write" and "Special" are enabled. Which kind of matches the permissions in the tar file. Whereas manually creating files usually inherits the rights ("Modify" and "Read & Execute").

Am I somehow able to prevent Tar from changing the permission (skip that step)? Or change them while reading the data and before changing the files' permission?

I'm using:

[[Tar]]
deps = ["ArgTools", "SHA"]
git-tree-sha1 = "c4b3a3a28f72ce90866d8a0fce2c61b201d1b693"
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.9.0"

with Julia version 1.5.3 (Win10). thanks a lot for your help

StefanKarpinski commented 3 years ago

@staticfloat, any thoughts on this? Since this is happening on 1.5.3, it seems like this isn't due to the 1.6 changes. On the flip side, is this fixed on 1.6?

staticfloat commented 3 years ago

@jdonnerstag can you try with Julia v1.5.4? or Julia v1.6? I think this may have already been fixed in both of those.