Commit 58de1d615660eb5d4c847daa1b86913adec2c4b1
Fix bugs
cel committed on 10/11/2017, 7:06:03 PMParent: 1c34dbba0a5af77002cfc4b22f75b89616bc991a
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -471,9 +471,9 @@ | ||
471 | 471 | }, function (err) { |
472 | 472 | if (err) return self.respondError(500, err.stack || err) |
473 | 473 | if (spec) resolveSpec() |
474 | 474 | else if (self.isNpm3 || self.isYarn) resolveAll() |
475 | - else self.respond(200, obj) | |
475 | + else done() | |
476 | 476 | }) |
477 | 477 | ) |
478 | 478 | function resolveSpec() { |
479 | 479 | var version = obj['dist-tags'][spec] |
@@ -481,24 +481,28 @@ | ||
481 | 481 | obj = obj.versions[version] |
482 | 482 | if (!obj) return self.respondError(404, 'version not found: ' + spec) |
483 | 483 | self.populatePackageJson(obj, function (err, pkg) { |
484 | 484 | if (err) return self.respondError(500, err.stack || err) |
485 | - self.respond(200, pkg || obj) | |
485 | + obj = pkg || obj | |
486 | + done() | |
486 | 487 | }) |
487 | 488 | } |
488 | 489 | function resolveAll() { |
489 | - // return self.respond(200, obj) | |
490 | 490 | var waiting = 0 |
491 | 491 | for (var version in obj.versions) (function (version) { |
492 | 492 | waiting++ |
493 | 493 | self.populatePackageJson(obj.versions[version], function (err, pkg) { |
494 | 494 | if (err && waiting <= 0) return console.trace(err) |
495 | 495 | if (err) return waiting = 0, self.respondError(500, err.stack || err) |
496 | 496 | if (pkg) obj.versions[version] = pkg |
497 | - if (!--waiting) self.respond(200, obj) | |
497 | + if (!--waiting) done() | |
498 | 498 | }) |
499 | 499 | }(version)) |
500 | + if (!waiting) done() | |
500 | 501 | } |
502 | + function done() { | |
503 | + self.respond(200, obj) | |
504 | + } | |
501 | 505 | } |
502 | 506 | |
503 | 507 | Req.prototype.servePrebuild = function (name) { |
504 | 508 | var self = this |
@@ -686,9 +690,9 @@ | ||
686 | 690 | cb(null, pkg) |
687 | 691 | }) |
688 | 692 | pull( |
689 | 693 | readBlob, |
690 | - hash('sha256', 'hex', function (err, sum) { | |
694 | + hash('sha1', 'hex', function (err, sum) { | |
691 | 695 | if (err) return cb(err) |
692 | 696 | shasum = sum |
693 | 697 | }), |
694 | 698 | toPull(zlib.createGunzip()), |
Built with git-ssb-web