{"action":"created","issue":{"url":"https://api.github.com/repos/maxogden/extract-zip/issues/13","labels_url":"https://api.github.com/repos/maxogden/extract-zip/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/maxogden/extract-zip/issues/13/comments","events_url":"https://api.github.com/repos/maxogden/extract-zip/issues/13/events","html_url":"https://github.com/maxogden/extract-zip/issues/13","id":114283967,"number":13,"title":"Error when extracting GitHub repo archive","user":{"login":"lukehorvat","id":1034878,"avatar_url":"https://avatars.githubusercontent.com/u/1034878?v=3","gravatar_id":"","url":"https://api.github.com/users/lukehorvat","html_url":"https://github.com/lukehorvat","followers_url":"https://api.github.com/users/lukehorvat/followers","following_url":"https://api.github.com/users/lukehorvat/following{/other_user}","gists_url":"https://api.github.com/users/lukehorvat/gists{/gist_id}","starred_url":"https://api.github.com/users/lukehorvat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukehorvat/subscriptions","organizations_url":"https://api.github.com/users/lukehorvat/orgs","repos_url":"https://api.github.com/users/lukehorvat/repos","events_url":"https://api.github.com/users/lukehorvat/events{/privacy}","received_events_url":"https://api.github.com/users/lukehorvat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-30T14:47:42Z","updated_at":"2015-11-06T18:33:17Z","closed_at":null,"body":"Trying to extract a repo archive downloaded from GitHub:\r\n \r\n```javascript\r\nconst fs = require(\"fs\");\r\nconst got = require(\"got\");\r\nconst extract = require(\"extract-zip\");\r\nconst pify = require(\"pify\");\r\n\r\ngot(\"https://codeload.github.com/maxogden/extract-zip/zip/master\", { encoding: null })\r\n.then(res => {\r\n  return pify(fs.writeFile)(\"master.zip\", res.body);\r\n}).then(() => {\r\n  return pify(extract)(\"master.zip\", { dir: process.cwd() });\r\n}).then(() => {\r\n  console.log(\"Done!\");\r\n}).catch(err => {\r\n  console.error(err);\r\n});\r\n```\r\n\r\nProduces the following error:\r\n\r\n```\r\nError: Callback was already called.\r\n    at /Users/lukehorvat/code/test1/node_modules/async/lib/async.js:30:31\r\n    at WriteStream.<anonymous> (/Users/lukehorvat/code/test1/node_modules/extract-zip/index.js:122:24)\r\n    at emitOne (events.js:82:20)\r\n    at WriteStream.emit (events.js:169:7)\r\n    at WriteStream.<anonymous> (fs.js:1846:12)\r\n    at FSReqWrap.oncomplete (fs.js:82:15)\r\n```\r\n\r\nI decided to print out the error above line 122 and it is as follows:\r\n\r\n```\r\nError: ENOENT: no such file or directory, open '/Users/lukehorvat/code/test1/extract-zip-master/'\r\n```\r\n\r\nAny idea what's going on here?"},"comment":{"url":"https://api.github.com/repos/maxogden/extract-zip/issues/comments/154494566","html_url":"https://github.com/maxogden/extract-zip/issues/13#issuecomment-154494566","issue_url":"https://api.github.com/repos/maxogden/extract-zip/issues/13","id":154494566,"user":{"login":"dedelp","id":3488344,"avatar_url":"https://avatars.githubusercontent.com/u/3488344?v=3","gravatar_id":"","url":"https://api.github.com/users/dedelp","html_url":"https://github.com/dedelp","followers_url":"https://api.github.com/users/dedelp/followers","following_url":"https://api.github.com/users/dedelp/following{/other_user}","gists_url":"https://api.github.com/users/dedelp/gists{/gist_id}","starred_url":"https://api.github.com/users/dedelp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dedelp/subscriptions","organizations_url":"https://api.github.com/users/dedelp/orgs","repos_url":"https://api.github.com/users/dedelp/repos","events_url":"https://api.github.com/users/dedelp/events{/privacy}","received_events_url":"https://api.github.com/users/dedelp/received_events","type":"User","site_admin":false},"created_at":"2015-11-06T18:33:17Z","updated_at":"2015-11-06T18:33:17Z","body":"I can confirm this on windows 7. It appears the directory is not being recognized as a directory. For reference, the externalFileAttributes=16.\r\nDoing some further investigation led me here http://stackoverflow.com/a/6297838 - specifically:\r\n```\r\nThe mapping of the external attributes is\r\n      host-system dependent (see 'version made by').  For\r\n      MS-DOS, the low order byte is the MS-DOS directory\r\n      attribute byte.  If input came from standard input, this\r\n      field is set to zero.\r\n```\r\nPer https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT - Upper byte of version made by = 0 for MS-DOS generated. \r\nFor a fix I am using the following\r\n```\r\n        var madeBy = entry.versionMadeBy >> 8\r\n        var isDir = (mode & IFMT) === IFDIR || (madeBy === 0 && entry.externalFileAttributes===16)\r\n```\r\nWorks fine with a few tests I did with windows generated and linux generated zip files, but I did not test it very extensively, nor check to see what else may need to be similarly changed (permissions?)."}}