isaacs/node-tar — Issue #1: Falls over extracting .bin folder
Author: DamonOehlman
Created: 2011-11-25 03:56:09+00:00
State: open

First - thanks for the awesome library, works wonderfully.

Just hit an issue that I managed to work around through trial and error, which seems to occur on RedHat Linux (we are using 5.7). The issue, however, does not occur on MacOS.

If a tar contains a `.bin` folder then the following exception is raised, when attempting to extract the library.

```
fs.js:223
binding.open(path, stringToFlags(flags), mode, callback);
^
TypeError: Bad argument
at Object._open (fs.js:223:11)
at open (/usr/local/steelmesh/node_modules/steelmesh-dash/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js:73:6)
at Object.open (/usr/local/steelmesh/node_modules/steelmesh-dash/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js:67:3)
at Object.lutimes (/usr/local/steelmesh/node_modules/steelmesh-dash/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js:28:6)
at setProps (/usr/local/steelmesh/node_modules/steelmesh-dash/node_modules/tar/node_modules/fstream/lib/writer.js:267:18)
at Object.oncomplete (/usr/local/steelmesh/node_modules/steelmesh-dash/node_modules/tar/node_modules/fstream/lib/writer.js:205:7)
```

Feel free to flick me an email (damon.oehlman -at- sidelab.com) and I'll be able to send you an archive that replicates the problem. Example code of how I'm running the extract process is below (I'm using the `write` interface rather than piping streams):

```js
fs.readFile(packageFile, function(err, input) {
if (err) {
callback({ errors: ['Could not read package' ]});
return;
}

// unzip the file
zlib.unzip(input, function(err, buffer) {
if (err) {
callback(_.extend(data, { errors: ['Could not unzip package '] }));
}
else {
// we have an in memory tar... time to process it
var extractor = new Extract({ path: _getPackageFolder(packageFile) });

extractor.on('entry', function() {
clearTimeout(callbackTimer);
callbackTimer = setTimeout(callback, 100);
});

// END handling doesn't seem to be working...
extractor.on('end', function() {
callback();
});

extractor.write(buffer);
}
});
});
```

Thanks again for taking the time to write a pure JS tar library :)

Cheers,
Damon.