index.jsView |
---|
1488 | 1488 | cat(!msg.content.packs ? [] : [ |
1489 | 1489 | pull.once('<h3>Commits</h3>'), |
1490 | 1490 | pull( |
1491 | 1491 | pull.values(msg.content.packs), |
1492 | | - paramap(function (pack, cb) { |
1493 | | - var key = pack.pack.link |
1494 | | - ssb.blobs.want(key, function (err, got) { |
1495 | | - if (err) cb(err) |
1496 | | - else if (!got) cb(null, pull.once('Missing blob ' + key)) |
1497 | | - else cb(null, ssb.blobs.get(key)) |
| 1492 | + pull.asyncMap(function (pack, cb) { |
| 1493 | + var done = multicb({ pluck: 1, spread: true }) |
| 1494 | + getBlob(pack.pack.link, done()) |
| 1495 | + getBlob(pack.idx.link, done()) |
| 1496 | + done(function (err, readPack, readIdx) { |
| 1497 | + if (err) return cb(renderError(err)) |
| 1498 | + cb(null, gitPack.decodeWithIndex(repo, readPack, readIdx)) |
1498 | 1499 | }) |
1499 | | - }, 8), |
1500 | | - pull.map(function (readPack, cb) { |
1501 | | - return gitPack.decode({}, repo, cb, readPack) |
1502 | 1500 | }), |
1503 | 1501 | pull.flatten(), |
1504 | | - paramap(function (obj, cb) { |
| 1502 | + pull.asyncMap(function (obj, cb) { |
1505 | 1503 | if (obj.type == 'commit') |
1506 | 1504 | Repo.getCommitParsed(obj, cb) |
1507 | 1505 | else |
1508 | 1506 | pull(obj.read, pull.drain(null, cb)) |
1509 | | - }, 8), |
| 1507 | + }), |
1510 | 1508 | pull.filter(), |
1511 | 1509 | pull.map(function (commit) { |
1512 | 1510 | return renderCommit(repo, commit) |
1513 | 1511 | }) |
1601 | 1599 | } |
1602 | 1600 | } |
1603 | 1601 | } |
1604 | 1602 | |
| 1603 | + function getBlob(key, cb) { |
| 1604 | + ssb.blobs.want(key, function (err, got) { |
| 1605 | + if (err) cb(err) |
| 1606 | + else if (!got) cb(new Error('Missing blob ' + key)) |
| 1607 | + else cb(null, ssb.blobs.get(key)) |
| 1608 | + }) |
| 1609 | + } |
| 1610 | + |
1605 | 1611 | function serveBlob(req, key) { |
1606 | | - return readNext(function (cb) { |
1607 | | - ssb.blobs.want(key, function (err, got) { |
1608 | | - if (err) cb(null, serveError(err)) |
1609 | | - else if (!got) cb(null, serve404(req)) |
1610 | | - else cb(null, serveRaw()(ssb.blobs.get(key))) |
1611 | | - }) |
| 1612 | + getBlob(key, function (err, read) { |
| 1613 | + if (err) cb(null, serveError(err)) |
| 1614 | + else if (!got) cb(null, serve404(req)) |
| 1615 | + else cb(null, serveRaw()(read)) |
1612 | 1616 | }) |
1613 | 1617 | } |
1614 | 1618 | |
1615 | 1619 | |