Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
dir-reader: revert a55ae72
Browse files Browse the repository at this point in the history
Unnecessary when collect() handles pause/resume state properly, this
compounds the issue and adds unnecessary entries to the list.

Credit: @rvagg
Reviewed-By: @othiym23
PR-URL: #53
  • Loading branch information
rvagg authored and othiym23 committed Jun 17, 2016
1 parent 688cf00 commit a67b90b
Showing 1 changed file with 5 additions and 9 deletions.
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

0 comments on commit a67b90b

Please sign in to comment.