Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Prevent addFiles timing out on empty filenames array
Browse files Browse the repository at this point in the history
If addFiles is passed an empty `filenames` array it will eventually 
timeout as the callback will never be called.  This change 
calls the callback immediately when `filenames.length` is 0.
  • Loading branch information
Danny Amey committed Feb 13, 2012
1 parent 5c50e68 commit ddd234d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions janzip/janzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ var Zip = function () {
}
};

if (!filenames.length) {
return callback && callback(fileErr);
}

filenames.forEach(function (f) {
fs.readFile(f.path, function (err, data) {
if (err) {
Expand Down

0 comments on commit ddd234d

Please sign in to comment.