|
@ -395,7 +395,7 @@ var FileReadStream = exports.FileReadStream = function(path, options) { |
|
|
|
|
|
|
|
|
var |
|
|
var |
|
|
self = this, |
|
|
self = this, |
|
|
buffer = []; |
|
|
buffer = null; |
|
|
|
|
|
|
|
|
function read() { |
|
|
function read() { |
|
|
if (!self.readable || self.paused) { |
|
|
if (!self.readable || self.paused) { |
|
@ -411,7 +411,7 @@ var FileReadStream = exports.FileReadStream = function(path, options) { |
|
|
|
|
|
|
|
|
// do not emit events if the stream is paused
|
|
|
// do not emit events if the stream is paused
|
|
|
if (self.paused) { |
|
|
if (self.paused) { |
|
|
buffer.push(data); |
|
|
buffer = data; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -450,15 +450,9 @@ var FileReadStream = exports.FileReadStream = function(path, options) { |
|
|
this.resume = function() { |
|
|
this.resume = function() { |
|
|
this.paused = false; |
|
|
this.paused = false; |
|
|
|
|
|
|
|
|
// emit any buffered read events before continuing
|
|
|
if (buffer !== null) { |
|
|
var data; |
|
|
self.emit('data', buffer); |
|
|
while (!this.paused) { |
|
|
buffer = null; |
|
|
data = buffer.shift(); |
|
|
|
|
|
if (data === undefined) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
self.emit('data', data); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
read(); |
|
|
read(); |
|
|