Commit 9da9f411b6480d9e5358ba0bc9c2ac00035edcd8
Fix receive pack callback
Make sure the callback gets called with any errors, only onceCharles Lehner committed on 2/19/2016, 4:35:32 AM
Parent: ae9b54b013d2d66a40e22128321e90346c34ec36
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -276,12 +276,12 @@ | ||
276 | 276 | } |
277 | 277 | |
278 | 278 | // receive-pack: push from client |
279 | 279 | function receivePack(read, repo, options) { |
280 | - var ended | |
281 | 280 | var sendRefs = receivePackHeader([ |
282 | 281 | 'delete-refs', |
283 | 282 | ], repo.refs(), true) |
283 | + var done = multicb({pluck: 1}) | |
284 | 284 | |
285 | 285 | return pktLine.encode( |
286 | 286 | cat([ |
287 | 287 | // send our refs |
@@ -296,17 +296,15 @@ | ||
296 | 296 | pull.collect(function (err, updates) { |
297 | 297 | if (err) return cb(err) |
298 | 298 | repo.update(pull.values(updates), pull( |
299 | 299 | lines.passthrough, |
300 | - pack.decode(repo, onEnd) | |
301 | - ), onEnd) | |
300 | + pack.decode(repo, done()) | |
301 | + ), done()) | |
302 | + done(function (err) { | |
303 | + cb(err || true) | |
304 | + }) | |
302 | 305 | }) |
303 | 306 | ) |
304 | - function onEnd(err) { | |
305 | - if (ended) return | |
306 | - ended = err || true | |
307 | - cb(err || true) | |
308 | - } | |
309 | 307 | }, |
310 | 308 | pull.once('unpack ok') |
311 | 309 | ]) |
312 | 310 | ) |
Built with git-ssb-web