Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module.exports = collect
function collect (stream) {
if (stream._collected) return

if (stream._paused) return stream.on('resume', collect.bind(null, stream))

stream._collected = true
stream.pause()

Expand Down
14 changes: 5 additions & 9 deletions lib/dir-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function DirReader (props) {
}

self.entries = null
self._entries = []
self._index = -1
self._paused = false
self._length = -1
Expand All @@ -48,7 +47,6 @@ DirReader.prototype._getEntries = function () {
if (er) return self.error(er)

self.entries = entries
self._entries = entries.slice()

self.emit('entries', entries)
if (self._paused) self.once('resume', processEntries)
Expand Down Expand Up @@ -76,7 +74,7 @@ DirReader.prototype._read = function () {
}

self._index++
if (self._index >= self._entries.length) {
if (self._index >= self.entries.length) {
if (!self._ended) {
self._ended = true
self.emit('end')
Expand All @@ -85,14 +83,12 @@ DirReader.prototype._read = function () {
return
}

// save creating a proxy, by stat'ing the thing now.
var nextEntry = self._entries[self._index]
if (!nextEntry) return this._read()

// ok, handle this one, then.
var p = path.resolve(self._path, nextEntry)

// save creating a proxy, by stat'ing the thing now.
var p = path.resolve(self._path, self.entries[self._index])
assert(p !== self._path)
assert(nextEntry)
assert(self.entries[self._index])

// set this to prevent trying to _read() again in the stat time.
self._currentEntry = p
Expand Down