Navigation Menu

Skip to content

Commit

Permalink
read callback should be called after everything was read.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed May 13, 2011
1 parent 8cded7a commit dd0854e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/fs.js
Expand Up @@ -560,13 +560,10 @@ exports.read = function read(fd, buffer, offset, length, position, callback) {
readStream.on("data", function onData(chunck) { readStream.on("data", function onData(chunck) {
chunck.copy(buffer, offset + bytesRead); chunck.copy(buffer, offset + bytesRead);
bytesRead += buffer.length; bytesRead += buffer.length;
if (bytesRead >= length) {
callback(null, bytesRead, buffer);
}
}); });
readStream.on("end", function onEnd() { readStream.on("end", function onEnd() {
callback(null, bytesRead, buffer);
readStream.destroy(); readStream.destroy();
console.log('The end!')
}); });
}; };


Expand Down

0 comments on commit dd0854e

Please sign in to comment.