Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more fixing things. todo: better logs.

  • Loading branch information...
commit d83e9004bdfd6f0ee54a911c0f6f7a53848817fa 1 parent aa3f4fe
@isaacs isaacs authored
View
26 lib/collect.js
@@ -32,43 +32,33 @@ function collect (stream) {
// unlock the buffered stuff. if you just call .pipe()
// without a destination, then it'll re-play the events.
stream.pipe = (function (orig) { return function (dest) {
+ console.error(" === open the pipes", dest && dest.path)
// let the entries flow through one at a time.
// Once they're all done, then we can resume completely.
var e = 0
;(function unblockEntry () {
var entry = entryBuffer[e++]
+ console.error(" ==== unblock entry", entry && entry.path)
if (!entry) return resume()
entry.on("end", unblockEntry)
- if (dest) dest.addEntry(entry)
+ if (dest) dest.add(entry)
else stream.emit("entry", entry)
})()
- if (!dest) {
- stream.pipe = orig
+ function resume () {
stream.removeListener("entry", saveEntry)
stream.removeListener("data", save)
stream.removeListener("end", save)
+
+ stream.pipe = orig
+ if (dest) stream.pipe(dest)
+
buf.forEach(function (b) {
if (b) stream.emit("data", b)
else stream.emit("end")
})
- stream.resume()
- return
- }
-
- function resume () {
- buf.forEach(function (b) {
- if (b) dest.write(b)
- else dest.end()
- })
-
- stream.removeListener("entry", saveEntry)
- stream.removeListener("data", save)
- stream.removeListener("end", save)
- stream.pipe = orig
- stream.pipe(dest)
stream.resume()
}
View
3  lib/dir-reader.js
@@ -102,7 +102,9 @@ DirReader.prototype._read = function () {
})
entry.on("ready", function EMITCHILD () {
+ console.error("DR emit child", entry.path)
if (me._paused) {
+ console.error(" DR emit child - try again later")
// pause the child, and emit the "entry" event once we drain.
// console.error("DR pausing child entry")
entry.pause(me)
@@ -126,7 +128,6 @@ DirReader.prototype._read = function () {
// proxy up some events.
; [ "error"
- , "data"
, "child"
, "childEnd"
, "warn"
View
1  lib/file-writer.js
@@ -63,6 +63,7 @@ FileWriter.prototype.write = function (c) {
}
var ret = me._stream.write(c)
+ console.error("\t-- fr wrote, _stream says", ret, me._stream._queue.length)
// allow 2 buffered writes, because otherwise there's just too
// much stop and go bs.
View
13 lib/proxy-writer.js
@@ -21,6 +21,7 @@ function ProxyWriter (props) {
"ProxyWriter must be called as constructor.")
me.props = props
+ me._needDrain = false
Writer.call(me, props)
}
@@ -48,6 +49,7 @@ ProxyWriter.prototype._stat = function () {
}
ProxyWriter.prototype._addProxy = function (proxy) {
+ console.error("~~ set proxy", this.path)
var me = this
if (me._proxy) {
return me.error("proxy already set")
@@ -67,31 +69,38 @@ ProxyWriter.prototype._addProxy = function (proxy) {
me.emit("proxy", proxy)
var calls = me._buffer
- me._buffer.length = 0
calls.forEach(function (c) {
- proxy[c[0]].apply(proxy, c[1])
+ console.error("~~ ~~ proxy buffered call", c[0], c[1])
+ proxy[c[0]].call(proxy, c[1])
})
+ me._buffer.length = 0
+ if (me._needsDrain) me.emit("drain")
}
ProxyWriter.prototype.add = function (entry) {
+ console.error("~~ proxy add")
collect(entry)
if (!this._proxy) {
this._buffer.push(["add", [entry]])
+ this._needDrain = true
return false
}
return this._proxy.add(entry)
}
ProxyWriter.prototype.write = function (c) {
+ console.error("~~ proxy write")
if (!this._proxy) {
this._buffer.push(["write", [c]])
+ this._needDrain = true
return false
}
return this._proxy.write(c)
}
ProxyWriter.prototype.end = function (c) {
+ console.error("~~ proxy end")
if (!this._proxy) {
this._buffer.push(["end", c])
return false
View
2  lib/reader.js
@@ -152,7 +152,7 @@ Reader.prototype._stat = function (currentStat) {
if (hardLinks[k] === me.path || !hardLinks[k]) hardLinks[k] = me.path
else {
// switch into hardlink mode.
- me.type = me.props.type = "Link"
+ type = me.type = me.props.type = "Link"
me.Link = me.props.Link = true
me.linkpath = me.props.linkpath = hardLinks[k]
console.error("Hardlink detected, switching mode", me.path, me.linkpath)
Please sign in to comment.
Something went wrong with that request. Please try again.