From bc7454fa1db558e89c8e8069d527c7b74a4ce60a Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 8 Jan 2018 15:48:04 -1000 Subject: Use readTreeFull and pull-catch --- lib/serve.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'lib/serve.js') diff --git a/lib/serve.js b/lib/serve.js index 7c42d0c..eb8610c 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -22,6 +22,7 @@ var ph = require('pull-hyperscript') var emojis = require('emoji-named-characters') var jpeg = require('jpeg-autorotate') var unzip = require('unzip') +var Catch = require('pull-catch') module.exports = Serve @@ -1788,7 +1789,12 @@ Serve.prototype.gitCommit = function (rev) { : file.mode ? 'mode changed' : JSON.stringify(file)) ]) - }) + }), + Catch(function (err) { + if (err && err.name === 'ObjectNotFoundError') return + if (err && err.name === 'BlobNotFoundError') return self.askWantBlobsForm(err.links) + return false + }) )) ] ]), @@ -1909,23 +1915,8 @@ Serve.prototype.gitTree = function (rev) { ]), missingBlobs ? self.askWantBlobsForm(missingBlobs) : ph('table', [ pull( - self.app.git.readTree(obj), - paramap(function (file, cb) { - self.app.git.getObjectMsg({ - obj: file.hash, - headMsgId: obj.msg.key, - }, function (err, msg) { - if (err && err.name === 'ObjectNotFoundError') return cb(null, file) - if (err && err.name === 'BlobNotFoundError') return cb(null, {missingBlobs: err.links}) - if (err) return cb(err) - file.msg = msg - cb(null, file) - }) - }, 8), + self.app.git.readTreeFull(obj), pull.map(function (item) { - if (item.missingBlobs) { - return self.askWantBlobsForm(item.missingBlobs) - } if (!item.msg) return ph('tr', [ ph('td', u.escapeHTML(item.name) + (item.type === 'tree' ? '/' : '')), @@ -1950,7 +1941,12 @@ Serve.prototype.gitTree = function (rev) { }, htime(fileDate)) ), ]) - }) + }), + Catch(function (err) { + if (err && err.name === 'ObjectNotFoundError') return + if (err && err.name === 'BlobNotFoundError') return self.askWantBlobsForm(err.links) + return false + }) ) ]), ]), -- cgit v1.2.3