fs.ReadStream: Passing null for file position on all reads except the first read of a range read.

This commit is contained in:
Evan Larkin 2010-09-26 22:31:09 -05:00 committed by Ryan Dahl
parent 265cda97d7
commit 914ff78df6

View File

@ -683,9 +683,8 @@ ReadStream.prototype._read = function () {
allocNewPool(); allocNewPool();
} }
if (this.start !== undefined && this.firstRead) { if (self.start !== undefined && self.firstRead) {
this.pos = this.start; self.pos = self.start;
this.firstRead = false;
} }
// Grab another reference to the pool in the case that while we're in the // Grab another reference to the pool in the case that while we're in the
@ -731,7 +730,10 @@ ReadStream.prototype._read = function () {
self._read(); self._read();
} }
fs.read(self.fd, pool, pool.used, toRead, this.pos, afterRead); // pass null for position after we've seeked to the start of a range read
// always pass null on a non-range read
fs.read(self.fd, pool, pool.used, toRead, (self.firstRead ? self.pos : null), afterRead);
self.firstRead = false;
if (self.pos !== undefined) { if (self.pos !== undefined) {
self.pos += toRead; self.pos += toRead;