{"action":"created","issue":{"url":"https://api.github.com/repos/archiverjs/node-archiver/issues/136","labels_url":"https://api.github.com/repos/archiverjs/node-archiver/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/archiverjs/node-archiver/issues/136/comments","events_url":"https://api.github.com/repos/archiverjs/node-archiver/issues/136/events","html_url":"https://github.com/archiverjs/node-archiver/issues/136","id":80007118,"number":136,"title":"Zip file permissions obtained from stat incorrect/inconsistent on Windows","user":{"login":"Tim-B","id":544941,"avatar_url":"https://avatars.githubusercontent.com/u/544941?v=3","gravatar_id":"","url":"https://api.github.com/users/Tim-B","html_url":"https://github.com/Tim-B","followers_url":"https://api.github.com/users/Tim-B/followers","following_url":"https://api.github.com/users/Tim-B/following{/other_user}","gists_url":"https://api.github.com/users/Tim-B/gists{/gist_id}","starred_url":"https://api.github.com/users/Tim-B/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tim-B/subscriptions","organizations_url":"https://api.github.com/users/Tim-B/orgs","repos_url":"https://api.github.com/users/Tim-B/repos","events_url":"https://api.github.com/users/Tim-B/events{/privacy}","received_events_url":"https://api.github.com/users/Tim-B/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-24T01:15:32Z","updated_at":"2015-09-10T01:07:52Z","closed_at":null,"body":"I've been investigating [an issue](https://github.com/Tim-B/grunt-aws-lambda/issues/6) on one of my own projects reported by Windows users, which I've been testing in a Windows VM and I think I've narrowed down the issue.\r\n\r\nIf you use .bulk() it obtains file permissions via stat, but on Windows these values seem incorrect.\r\n\r\nHere's the output of a very simple example zip run through zipinfo:\r\n\r\nWhen generated from Ubuntu:\r\n```\r\nArchive:  output_ubuntu.zip\r\nZip file size: 376 bytes, number of entries: 3\r\ndrwxrwxr-x  4.5 unx        0 b- stor 15-May-24 00:46 folder1/\r\ndrwxrwxr-x  4.5 unx        0 b- stor 15-May-24 00:47 folder1/folder2/\r\n-rw-rw-r--  4.5 unx       12 bl defN 15-May-24 00:47 folder1/folder2/test.txt\r\n3 files, 12 bytes uncompressed, 14 bytes compressed:  -16.7%\r\n```\r\n\r\nWhen generated from Windows:\r\n```\r\nArchive:  output_windows.zip\r\nZip file size: 376 bytes, number of entries: 3\r\ndrw-rw-rw-  4.5 unx        0 b- stor 15-May-24 00:53 folder1/\r\ndrw-rw-rw-  4.5 unx        0 b- stor 15-May-24 00:53 folder1/folder2/\r\n-rw-rw-rw-  4.5 unx       12 bl defN 15-May-24 00:47 folder1/folder2/test.txt\r\n3 files, 12 bytes uncompressed, 14 bytes compressed:  -16.7%\r\n```\r\n\r\nNote that the directories on Windows don't have the execute bit set, which causes problems on some systems which extract them.\r\n\r\nI did some further debugging and printed some debugging information around the [stat code](https://github.com/archiverjs/node-archiver/blob/master/lib/core.js#L193) and noticed the following:\r\n\r\nFor a directory:\r\n```\r\ndata.stats.mode = 16822\r\ndata.mode = 438 after line 196\r\n```\r\nWhich is what you'd expect seeing as `16822 & 0777` is 438 which is `110110110` in binary, ie. 666 in octal.\r\n\r\nHere's some files to help you replicate the issue:\r\n* [Ubuntu example zip](https://drive.google.com/open?id=0BxZ36NMP6tk2NHdnOTZXR0gxVHM&authuser=0) \r\n* [Windows example zip](https://drive.google.com/open?id=0BxZ36NMP6tk2eWJjQmpHd2xaN2M&authuser=0) \r\n* [Example script to generate zip](https://drive.google.com/open?id=0BxZ36NMP6tk2Nl8xcUh0anpGZHM&authuser=0) \r\n"},"comment":{"url":"https://api.github.com/repos/archiverjs/node-archiver/issues/comments/139084083","html_url":"https://github.com/archiverjs/node-archiver/issues/136#issuecomment-139084083","issue_url":"https://api.github.com/repos/archiverjs/node-archiver/issues/136","id":139084083,"user":{"login":"Tim-B","id":544941,"avatar_url":"https://avatars.githubusercontent.com/u/544941?v=3","gravatar_id":"","url":"https://api.github.com/users/Tim-B","html_url":"https://github.com/Tim-B","followers_url":"https://api.github.com/users/Tim-B/followers","following_url":"https://api.github.com/users/Tim-B/following{/other_user}","gists_url":"https://api.github.com/users/Tim-B/gists{/gist_id}","starred_url":"https://api.github.com/users/Tim-B/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tim-B/subscriptions","organizations_url":"https://api.github.com/users/Tim-B/orgs","repos_url":"https://api.github.com/users/Tim-B/repos","events_url":"https://api.github.com/users/Tim-B/events{/privacy}","received_events_url":"https://api.github.com/users/Tim-B/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T01:07:52Z","updated_at":"2015-09-10T01:07:52Z","body":"You can find another possible workaround here: https://github.com/Tim-B/grunt-aws-lambda/blob/master/tasks/lambda_package.js#L77\r\n\r\nIt doesn't require you to maintain a separate copy of node-archiver that way, although you'd probably still want to lock your version."}}