Fix style; undefined reference bug

pull/5370/head
Ryan Dahl 2010-09-08 12:03:33 -07:00
parent ccf4afa256
commit 0e501f4ec5
1 changed files with 8 additions and 6 deletions

View File

@ -611,6 +611,8 @@ fs.createReadStream = function(path, options) {
var ReadStream = fs.ReadStream = function(path, options) {
events.EventEmitter.call(this);
var self = this;
this.path = path;
this.fd = null;
this.readable = true;
@ -629,11 +631,12 @@ var ReadStream = fs.ReadStream = function(path, options) {
this[key] = options[key];
}
if(this.start || this.end) {
if(this.start === undefined || this.end === undefined) {
self.emit('error', new Error('Both start and end are needed for range streaming.'));
} else if(this.start > this.end) {
self.emit('error', new Error('start must be <= end'));
if (this.start || this.end) {
if (this.start === undefined || this.end === undefined) {
this.emit('error',
new Error('Both start and end are needed for range streaming.'));
} else if (this.start > this.end) {
this.emit('error', new Error('start must be <= end'));
} else {
this.firstRead = true;
}
@ -643,7 +646,6 @@ var ReadStream = fs.ReadStream = function(path, options) {
return;
}
var self = this;
fs.open(this.path, this.flags, this.mode, function(err, fd) {
if (err) {
self.emit('error', err);