Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue 37, where entry.size is undefined. #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,20 @@ Parse.prototype._readFile = function () {
if (err) {
return self.emit('error', err);
}
fileName = fileName.toString('utf8');

var entry = new Entry();
var fileSizeKnown = !(vars.flags & 0x08);

fileName = fileName.toString('utf8');

entry.path = fileName;
entry.props.path = fileName;
entry.type = (vars.compressedSize === 0 && /[\/\\]$/.test(fileName)) ? 'Directory' : 'File';

if (entry.type === 'File' && fileSizeKnown) {
entry.size = vars.uncompressedSize;
}

if (self._opts.verbose) {
if (entry.type === 'Directory') {
console.log(' creating:', fileName);
Expand Down Expand Up @@ -127,15 +135,12 @@ Parse.prototype._readFile = function () {
return self._readRecord();
});
} else {
var fileSizeKnown = !(vars.flags & 0x08);

var inflater = zlib.createInflateRaw();
inflater.on('error', function (err) {
self.emit('error', err);
});

if (fileSizeKnown) {
entry.size = vars.uncompressedSize;
if (hasEntryListener) {
entry.on('finish', self._readRecord.bind(self));
self._pullStream.pipe(vars.compressedSize, inflater).pipe(entry);
Expand Down