Skip to content

Commit 83e9ccc

Browse files
committed
don't call pumpEntries recursively. closes #9.
1 parent 50941a7 commit 83e9ccc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ ZipFile.prototype.addReadStream = function(readStream, metadataPath, options) {
5151
entry.setFileDataPumpFunction(function() {
5252
entry.state = Entry.FILE_DATA_IN_PROGRESS;
5353
pumpFileDataReadStream(self, entry, readStream);
54-
pumpEntries(self);
5554
});
5655
pumpEntries(self);
5756
};
@@ -78,7 +77,12 @@ ZipFile.prototype.addBuffer = function(buffer, metadataPath, options) {
7877
writeToOutputStream(self, compressedBuffer);
7978
writeToOutputStream(self, entry.getFileDescriptor());
8079
entry.state = Entry.FILE_DATA_DONE;
81-
pumpEntries(self);
80+
81+
// don't call pumpEntries() recursively.
82+
// (also, don't call process.nextTick recursively.)
83+
setImmediate(function() {
84+
pumpEntries(self);
85+
});
8286
});
8387
pumpEntries(self);
8488
}
@@ -274,6 +278,7 @@ Entry.prototype.setFileAttributesMode = function(mode) {
274278
// http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute/14727#14727
275279
this.externalFileAttributes = (mode << 16) >>> 0;
276280
};
281+
// doFileDataPump() should not call pumpEntries() directly. see issue #9.
277282
Entry.prototype.setFileDataPumpFunction = function(doFileDataPump) {
278283
this.doFileDataPump = doFileDataPump;
279284
this.state = Entry.READY_TO_PUMP_FILE_DATA;

0 commit comments

Comments
 (0)