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

Commit

Permalink
More complete pause coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Nov 8, 2011
1 parent d07161d commit 1b69092
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/dir-reader.js
Expand Up @@ -52,6 +52,7 @@ DirReader.prototype._read = function () {
if (!me._entries) return me._getEntries()

if (me._paused || me._currentEntry || me._aborted) {
// console.error("DR paused=%j, current=%j, aborted=%j", me._paused, !!me._currentEntry, me._aborted)
return
}

Expand Down Expand Up @@ -101,6 +102,10 @@ DirReader.prototype._read = function () {
})

entry.on("ready", function () {
if (me._paused) {
// console.error("pausing child entry")
entry.pause()
}
me.emit("entry", entry)
me.emit("child", entry)
})
Expand Down Expand Up @@ -140,9 +145,16 @@ DirReader.prototype.pause = function () {

DirReader.prototype.resume = function () {
var me = this
if (!me._paused) return
me._paused = false
if (me._currentEntry && me._currentEntry.resume) {
me._currentEntry.resume()
} else me._read()
me.emit("resume")
if (me._paused) {
// console.error("DR Re-paused", me.path)
return
}
if (me._currentEntry) {
if (me._currentEntry.resume) {
me._currentEntry.resume()
}
} else me._read()
}

0 comments on commit 1b69092

Please sign in to comment.