node-unzip icon indicating copy to clipboard operation
node-unzip copied to clipboard

not preserving the exec permission on zip extraction

Open lquixada opened this issue 12 years ago • 7 comments

If any compressed file had exec permission before compression, it will lose its permission on extraction.

Enviroment: OS X 10.8.2 Node 0.8.12 NPM 1.1.63

Steps:

git clone https://github.com/nearinfinity/node-unzip.git
cd node-unzip
npm install
touch blah
chmod +x blah
ls -la blah
echo "blah has exec permission."
zip blah.zip blah 
rm blah
node -e "require('fs').createReadStream('./blah.zip').pipe(require('./unzip').Extract({ path: '.' }));"
ls -la blah
echo "Now, blah was supposed to have exec permission but it doesn't."

lquixada avatar Oct 26 '12 01:10 lquixada

Unzipping with the correct file permissions isn't implemented right now. I'll add support this weekend / early next week. Thanks for reporting the issue.

EvanOxfeld avatar Oct 26 '12 17:10 EvanOxfeld

+1

satazor avatar Nov 11 '12 12:11 satazor

I'm revisiting the design impact of permissions, as well as anything else stored in the central directory file headers at the end of the zip - see #1 and #2, after being waylaid (in a fun way) by Node Knockout. Unzip needs to decompress arbitrary zip streams, and currently does so in one incredibly fast pass in the improve-speed branch. I should be able to write each file to disk, then when the central directory headers are streamed modify files as specified.

While I'm giving this issue more thought, suggestions or pull requests (even better!) are welcome.

EvanOxfeld avatar Nov 13 '12 17:11 EvanOxfeld

Hello, I made some modifications to apply permission which apparently were working fine on node-unzip 0.1.2.

I ported my fix on node-unzip 0.1.3, and now I see (not always) an error saying that the file does not exist when I try to execute the fs.chmod.

It seems that the _readCentralDirectoryFileHeader() is called while the file is still being written to disk and not yet closed.

My feeling is that we should wait until all the files are written to disk before processing the central directory entries. Any thoughts, ideas ?

yves-del-medico avatar Feb 18 '13 14:02 yves-del-medico

is this still open? any update? I really need the permissions to be kept. currently manually resetting permissions. again to each file. would like to have a clean solution.

@EvanOxfeld Is this issue resolved? Or is there any flag I can pass to unzip.extract in order to preserve the file permissions?

mayankchutani avatar Jun 08 '18 09:06 mayankchutani

still not fixed?

ThibaultJanBeyer avatar Jan 29 '19 13:01 ThibaultJanBeyer