Fix zip files created on Windows being unusable on Linux/MacOS (missing executable bits on directories) #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a caller passes in a
mode
on theaddEmptyDirectory()
call, and that mode is taken directly from the (albeit platform-specific)fs.stat()
'smode
, we end up creating zip files with directories that do not have the executable bit, which makes them completely unopenable on some platforms (MacOS Finder), and creates bad directory entries on others (Linux).I also couldn't help but fix
setFileAttributesMode
to always set either S_IFDIR or S_IFREG, since it seemed really weird that it was only sometimes setting it (only if mode === null). This isn't to fix any observed bug, so I'd be perfectly fine sending a PR without that part of the change if needed for some reason, but I'm guessing all zip clients ignore those two flags anyway, so it probably doesn't matter ^_^.This would resolve the following issues:
sindresorhus/gulp-zip#76
sindresorhus/gulp-zip#106
sindresorhus/gulp-zip#112
Some discussion about trying to work around it at a higher level here: sindresorhus/gulp-zip#117 . Ending conclusion was that there's probably no reasonable situation in which we would want
yazl
to be creating zip files that cannot be opened on some platforms, so if it's writing platform-specific mode bits, it makes sense to massage them to be portable.