max-mapper / max-mapper/extract-zip
[BUG] Files created in readonly - Callback already called + write error on next write.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 398
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
Please keep in mind that I am trying this on an older Node Webkit 0.12.0 on Windows XP, 7, 8, 10.
Seems I have to use this version for windows XP support but its node version is higher than the required one for this module.
write error Objecterror: Errorcode: "EPERM"errno: -4048message: "EPERM: operation not permitted, open 'E:\TEST\gfdsgasd\TEST.txt'"path: "E:\TEST\gfdsgasd\TEST.txt"
My zip file contains a text file that is it.
The odd thing is when I goto the file on disk it is there but empty (probably from a previous attempt)
I deleted everything and ran again and it worked which indicates it can't overwrite existing files or directories.
DOH Its creating the file in read only mode. When I zipped the file it was not read only so the permission is being incorrectly set on here.
Ah here is a fix
Line 67-71 of extract-zip/index.js
// if no mode then use the default.
if (mode === 0) {
if (isDir) mode = 0555
else mode = 0666 //mode = 0444 read only
}
Maybe there should have a way to specify the default mode if none is set?
Although if I am extracting a file from a ZIP I would kind of expect it to default to writable at least for my user and createWriteStream + other file write methods default to 0666 so I think that should be the default.
What are your thoughts on this?
Sample code
extractZip(path, { dir: 'E:\\TEST' }, function(err) {
console.log('extracted', err);
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in extract-zip/index.js around lines 67-71, where the default mode for extracted files is selected. Run the provided extractZip sample against an archive containing a text file and verify that an existing destination file is writable and no callback or subsequent-write error occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100