Commit 768670b4c7e5fe519e7fcd47c00f692fcfadaf21
Let newer dist-tag updates take precedence
re: %1kWUe02L1DP5+XWKFKlgSviEYXCuzx+xzaXIeVY6aYU=.sha256cel committed on 12/11/2017, 6:36:24 AM
Parent: 9a4aec35b080e6a7dd68a561c6fe650319bc07e5
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -609,14 +609,22 @@ | ||
609 | 609 | name: pkgName, |
610 | 610 | 'dist-tags': {}, |
611 | 611 | versions: {} |
612 | 612 | } |
613 | + var distTags = {/* <tag>: {version, ts}*/} | |
613 | 614 | pull( |
614 | 615 | self.server.getMentions({$prefix: 'npm:' + pkgName + ':'}), |
615 | 616 | pull.drain(function (mention) { |
616 | 617 | var data = decodeName(mention.name) |
617 | 618 | if (!data.version) return |
618 | - if (data.distTag) obj['dist-tags'][data.distTag] = data.version | |
619 | + if (data.distTag) { | |
620 | + var tag = distTags[data.distTag] | |
621 | + if (!tag || mention.ts > tag.ts) { | |
622 | + /* TODO: sort by causal order (versionBranch links) instead of just | |
623 | + * by timestamps */ | |
624 | + distTags[data.distTag] = {ts: mention.ts, version: data.version} | |
625 | + } | |
626 | + } | |
619 | 627 | obj.versions[data.version] = { |
620 | 628 | author: { |
621 | 629 | url: mention.author |
622 | 630 | }, |
@@ -625,8 +633,11 @@ | ||
625 | 633 | dist: self.server.blobDist(mention.link) |
626 | 634 | } |
627 | 635 | }, function (err) { |
628 | 636 | if (err) return self.respondError(500, err.stack || err) |
637 | + for (var tag in distTags) { | |
638 | + obj['dist-tags'][tag] = distTags[tag].version | |
639 | + } | |
629 | 640 | if (spec) resolveSpec() |
630 | 641 | else if (self.fetchAll) resolveAll() |
631 | 642 | else done() |
632 | 643 | }) |
Built with git-ssb-web