Skip to content

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

@jdonnerstag

Description

@jdonnerstag

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions