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

Zip decompression throws "permission denied" when archive directory does not have write permission #761

Open
rcorre opened this issue Dec 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@rcorre
Copy link

rcorre commented Dec 27, 2024

Version

ouch 0.5.1

Description

ouch d fails to decmpress an archive where a folder does not have write permission. unzip is able to decompress the same archive.

❯ tree -p example
[drwx------]  example
└── [dr-x------]  foo
    └── [-rw-------]  bar

❯ ouch c example/ example.zip
[INFO] Compressing 'example'.
[INFO] Compressing 'example/foo'.
[INFO] Compressing 'example/foo/bar'.
[INFO] Successfully compressed 'example.zip'.

❯ ouch d example.zip -d out
[INFO] Directory out created.
[INFO] Created temporary directory /tmp/out/.tmpYlmrmN to hold decompressed elements.
[INFO] File 0 extracted to "/tmp/out/.tmpYlmrmN/example/"
[INFO] File 1 extracted to "/tmp/out/.tmpYlmrmN/example/foo/"
[INFO] "out/.tmpYlmrmN/example/foo/bar" extracted. (0 B)
[ERROR] failed to create file `out/.tmpYlmrmN/example/foo/bar`
 - Permission denied

❯ unzip example.zip -d out
Archive:  example.zip
   creating: out/example/
   creating: out/example/foo/
  inflating: out/example/foo/bar     

example.zip

Note that unzip does mirror the permissions in the resulting directory:

❯ tree -p out/
[drwx------]  out/
└── [drwx------]  example
    └── [dr-x------]  foo
        └── [-rw-------]  bar

I'm guessing that unzip unpacks everything in a directory before setting that directory's permisions, whereas ouch is setting permissions on a directory before it tries to write that directory's children.

Current Behavior

No response

Expected Behavior

No response

Additional Information

No response

@rcorre rcorre added the bug Something isn't working label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant