Permalink
Browse files

fs.ReadStream: Passing null for file position on all reads except the…

… first read of a range read.
  • Loading branch information...
1 parent d29e62d commit 16f736200a176f8b6d644fccdda6e77891993c06 @elarkin elarkin committed with ry Sep 27, 2010
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/fs.js
View
@@ -671,9 +671,8 @@ ReadStream.prototype._read = function () {
allocNewPool();
}
- if (this.start !== undefined && this.firstRead) {
- this.pos = this.start;
- this.firstRead = false;
+ if (self.start !== undefined && self.firstRead) {
+ self.pos = self.start;
}
// Grab another reference to the pool in the case that while we're in the
@@ -719,7 +718,10 @@ ReadStream.prototype._read = function () {
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) {
self.pos += toRead;

0 comments on commit 16f7362

Please sign in to comment.