Removed range read optimization as it doesn't work with libeio.
This commit is contained in:
parent
2fa260cef6
commit
2b08bacd56
10
lib/fs.js
10
lib/fs.js
@ -643,7 +643,7 @@ var ReadStream = fs.ReadStream = function(path, options) {
|
|||||||
} else if (this.start > this.end) {
|
} else if (this.start > this.end) {
|
||||||
this.emit('error', new Error('start must be <= end'));
|
this.emit('error', new Error('start must be <= end'));
|
||||||
} else {
|
} else {
|
||||||
this.firstRead = true;
|
this._firstRead = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,8 +684,9 @@ ReadStream.prototype._read = function () {
|
|||||||
allocNewPool();
|
allocNewPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.start !== undefined && self.firstRead) {
|
if (self.start !== undefined && self._firstRead) {
|
||||||
self.pos = self.start;
|
self.pos = self.start;
|
||||||
|
self._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,10 +732,7 @@ ReadStream.prototype._read = function () {
|
|||||||
self._read();
|
self._read();
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass null for position after we've seeked to the start of a range read
|
fs.read(self.fd, pool, pool.used, toRead, self.pos, afterRead);
|
||||||
// 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;
|
||||||
|
@ -87,13 +87,13 @@ process.addListener('exit', function() {
|
|||||||
assert.equal(10000, file3.length);
|
assert.equal(10000, file3.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
var file4 = fs.createReadStream(rangeFile, {start: 1, end: 2});
|
var file4 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1, end: 2});
|
||||||
var contentRead = '';
|
var contentRead = '';
|
||||||
file4.addListener('data', function(data) {
|
file4.addListener('data', function(data) {
|
||||||
contentRead += data.toString('utf-8');
|
contentRead += data.toString('utf-8');
|
||||||
});
|
});
|
||||||
file4.addListener('end', function(data) {
|
file4.addListener('end', function(data) {
|
||||||
assert.equal(contentRead, 'yz');
|
assert.equal(contentRead, 'yz');
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -119,4 +119,4 @@ stream.on('data', function(chunk){
|
|||||||
|
|
||||||
stream.on('end', function(){
|
stream.on('end', function(){
|
||||||
assert.equal('x', stream.data);
|
assert.equal('x', stream.data);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user