-
Notifications
You must be signed in to change notification settings - Fork 79
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
File permissions changed while unzipping. #101
Comments
yauzl does not write to the file system. This line from your example is where the file is being created: let outputStream = fs.createWriteStream('./' + entry.fileName) or possibly this line; i'm not familiar with the libraries you're using: fs.ensureFile(path.join('./', entry.fileName), ...) You'll need to set the file permission bits yourself. See the readme for how to get the file permissions from yauzl. |
Ah I see. Thank you for explanation. I will have to change this line. let outputStream = fs.createWriteStream('./' + entry.fileName, {mode: entry.externalFileAttributes}) But |
Ah sorry! I was thinking of the docs for yazl. My mistake. If you trust that your zip files are all coming from a UNIX-like zipfile creator, then you can use this: {mode: entry.externalFileAttributes >>> 16} I have not done an analysis to see how common it is to encode the permission bits like this in the external file attributes, but I know it is typical in at least some situations. The meaning of the external file attributes is not specified by the zipfile specification. It's probably appropriate for me to do this investigation and have a getter function in the Entry class like I do for |
It works! I was missing two things.
Regarding yauzl code change, if the method is about this much only, then I can raise a PR with this code and appropriate README changes. let getLastModDate = function () {
return entry.externalFileAttributes >>> 16
} I will leave this PR to your discretion. You can keep it open to track the changes, or close it. |
I opened #102 to implement the method. |
Yauzl library is incorrectly unzipping my file permissions. Below is a test file.
Output
I have also verified that in Line 287, the same value as
zipped
is read, so I am not sure why the file is not set with correct permissions.The text was updated successfully, but these errors were encountered: