Commit e6b9c24e5ee9397fd4807d48300ea1511f41a55e
Don't send empty pack
Charles Lehner committed on 7/30/2016, 9:13:23 PMParent: 447d29c36ed45ee032fa6a0992dbfe00cde5c370
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -71,8 +71,9 @@ | ||
71 | 71 | var sendPack |
72 | 72 | var wants = {} |
73 | 73 | var shallows = {} |
74 | 74 | var aborted |
75 | + var hasWants | |
75 | 76 | var gotWants |
76 | 77 | |
77 | 78 | function readWant(abort, cb) { |
78 | 79 | if (abort) return |
@@ -84,8 +85,9 @@ | ||
84 | 85 | return |
85 | 86 | } |
86 | 87 | if (want.type == 'want') { |
87 | 88 | wants[want.hash] = true |
89 | + hasWants = true | |
88 | 90 | } else if (want.type == 'shallow') { |
89 | 91 | shallows[want.hash] = true |
90 | 92 | } else { |
91 | 93 | var err = new Error("Unknown thing", want.type, want.hash) |
@@ -139,13 +141,14 @@ | ||
139 | 141 | else readHave(abort, cb) |
140 | 142 | } |
141 | 143 | ])), |
142 | 144 | |
143 | - function havesDone(abort, cb) { | |
145 | + function (abort, cb) { | |
144 | 146 | if (abort || aborted) return cb(abort || aborted) |
145 | 147 | // send pack file to client |
146 | 148 | if (sendPack) |
147 | 149 | return sendPack(abort, cb) |
150 | + if (!hasWants) return cb(true) | |
148 | 151 | getObjects(repo, commonHash, wants, shallows, |
149 | 152 | function (err, numObjects, readObjects) { |
150 | 153 | if (err) return cb(err) |
151 | 154 | var progress = progressObjects(options) |
@@ -517,17 +520,9 @@ | ||
517 | 520 | cb(err, data) |
518 | 521 | else |
519 | 522 | next(abort, cb) |
520 | 523 | } else { |
521 | - // HACK: silence error when writing to closed stream | |
522 | - try { | |
523 | - cb(null, data) | |
524 | - } catch(e) { | |
525 | - if (e.message == 'process.stdout cannot be closed.' | |
526 | - || e.message == 'This socket is closed.') | |
527 | - process.exit(1) | |
528 | - throw e | |
529 | - } | |
524 | + cb(null, data) | |
530 | 525 | } |
531 | 526 | }) |
532 | 527 | } |
533 | 528 | } |
Built with git-ssb-web