Skip to content

Commit

Permalink
stream: the position of _read() is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyou2012 committed Apr 19, 2021
1 parent ee9e2a2 commit e6de79d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/internal/fs/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ ReadStream.prototype._read = function(n) {
if (er) {
errorOrDestroy(this, er);
} else if (bytesRead > 0) {
if (this.pos !== undefined) {
this.pos += bytesRead;
}

this.bytesRead += bytesRead;

if (bytesRead !== buf.length) {
Expand All @@ -271,10 +275,6 @@ ReadStream.prototype._read = function(n) {
this.push(null);
}
});

if (this.pos !== undefined) {
this.pos += n;
}
};

ReadStream.prototype._destroy = function(err, cb) {
Expand Down

0 comments on commit e6de79d

Please sign in to comment.