aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-08 15:48:04 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-08 16:01:28 -1000
commitbc7454fa1db558e89c8e8069d527c7b74a4ce60a (patch)
tree5d3c570a2e5eb1cd2c9f40cf029c559c1ff0ad75
parenta6b3929f8e156244dc22cae546a15079c1754f48 (diff)
downloadpatchfoo-bc7454fa1db558e89c8e8069d527c7b74a4ce60a.tar.gz
patchfoo-bc7454fa1db558e89c8e8069d527c7b74a4ce60a.zip
Use readTreeFull and pull-catch
-rw-r--r--lib/serve.js32
-rw-r--r--package-lock.json46
-rw-r--r--package.json1
3 files changed, 46 insertions, 33 deletions
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
+ })
)
]),
]),
diff --git a/package-lock.json b/package-lock.json
index 0f5d62f..8d381d4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -492,6 +492,7 @@
"readable-stream": {
"version": "1.0.34",
"resolved": "http://localhost:8989/blobs/get/&0QEMlyAUePLZCW/tXOEhdYfVI4R19FBv4JyHzdW8VqY=.sha256",
+ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "http://localhost:8989/blobs/get/&pKRNq2V57ePgat5Y0m+P1kLq4JFT/VnGCPy3lRpJk5g=.sha256",
"inherits": "2.0.3",
@@ -772,17 +773,15 @@
"resolved": "http://localhost:8989/blobs/get/&+uVE8RHNwJIJa68sQGICGbxnCTCOdLLhSt/Pb4NmgL0=.sha256",
"integrity": "sha256-+uVE8RHNwJIJa68sQGICGbxnCTCOdLLhSt/Pb4NmgL0="
},
+ "pull-catch": {
+ "version": "1.0.0",
+ "resolved": "http://localhost:8989/blobs/get/&K8t9klRhYJkdveaxSpBMFwzMtmNyLwNRTQUeCVnUvYU=.sha256",
+ "integrity": "sha256-K8t9klRhYJkdveaxSpBMFwzMtmNyLwNRTQUeCVnUvYU="
+ },
"pull-defer": {
"version": "http://localhost:8989/blobs/get/&mDI2o/JC9yvFOVbeAhDN+hwTm7cK+dBwISYO49EMY24=.sha256",
"integrity": "sha1-CIew/7MK8ypW2+z6csFnInHwexM="
},
- "pull-git-packidx-parser": {
- "version": "http://localhost:8989/blobs/get/&ou0MPQZabBgzrHDu54jzLU3Sc6Rf5a/lost0whPQUJ0=.sha256",
- "integrity": "sha1-LYvwr+SCSJfuA4QL/k9ahq/syiE=",
- "requires": {
- "pull-stream": "3.6.1"
- }
- },
"pull-goodbye": {
"version": "0.0.2",
"resolved": "http://localhost:8989/blobs/get/&MQhN9Pp3BYaj0TzxK39JfAK7CjVceg1EPfNhhFnZ9sU=.sha256",
@@ -842,14 +841,6 @@
}
}
},
- "pull-kvdiff": {
- "version": "0.0.1",
- "resolved": "http://localhost:8989/blobs/get/&xxfT88LrbK4FSIhpaNmIAt4jzsaBgVugeaDPVwC1gCU=.sha256",
- "integrity": "sha256-xxfT88LrbK4FSIhpaNmIAt4jzsaBgVugeaDPVwC1gCU=",
- "requires": {
- "multicb": "1.2.2"
- }
- },
"pull-many": {
"version": "http://localhost:8989/blobs/get/&wBHfPheBEjwjjkNoeM5mWtU/tYDs8+xnt5w6C1+EK3g=.sha256",
"integrity": "sha1-Pa3ZttFWxUVyG9qNAAPdjqoGKT4=",
@@ -928,6 +919,7 @@
"readable-stream": {
"version": "1.0.34",
"resolved": "http://localhost:8989/blobs/get/&0QEMlyAUePLZCW/tXOEhdYfVI4R19FBv4JyHzdW8VqY=.sha256",
+ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "http://localhost:8989/blobs/get/&pKRNq2V57ePgat5Y0m+P1kLq4JFT/VnGCPy3lRpJk5g=.sha256",
"inherits": "2.0.3",
@@ -1069,6 +1061,7 @@
"readable-stream": {
"version": "1.0.34",
"resolved": "http://localhost:8989/blobs/get/&0QEMlyAUePLZCW/tXOEhdYfVI4R19FBv4JyHzdW8VqY=.sha256",
+ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "http://localhost:8989/blobs/get/&pKRNq2V57ePgat5Y0m+P1kLq4JFT/VnGCPy3lRpJk5g=.sha256",
"inherits": "2.0.3",
@@ -1206,6 +1199,28 @@
"version": "http://localhost:8989/blobs/get/&5yyYBZpB4w+X6kW42KMh43Xz9KP3XW79mYOj40/CHA4=.sha256",
"integrity": "sha1-Fg4kETeCqcpegGByqnpl58hl2/I="
},
+ "ssb-mentions": {
+ "version": "http://localhost:8989/blobs/get/&GjuxknqKwJqHznKueFNCyIh52v1woz5PB41vqmoHfyM=.sha256",
+ "integrity": "sha1-AMd4SslTCsJi2h5902MlCCA1UEY=",
+ "requires": {
+ "ssb-marked": "http://localhost:8989/blobs/get/&5yyYBZpB4w+X6kW42KMh43Xz9KP3XW79mYOj40/CHA4=.sha256",
+ "ssb-ref": "2.7.1"
+ },
+ "dependencies": {
+ "is-valid-domain": {
+ "version": "0.0.2",
+ "resolved": "http://localhost:8989/blobs/get/&phjiap+k1lGC5LPVba/w4Caomw5o0NQp2Hol+u/YAzE=.sha256"
+ },
+ "ssb-ref": {
+ "version": "2.7.1",
+ "resolved": "http://localhost:8989/blobs/get/&wLimOD3785KVj7kBIAbjN6GH8EMhKRkcZSPrEMhdhks=.sha256",
+ "requires": {
+ "ip": "1.1.5",
+ "is-valid-domain": "0.0.2"
+ }
+ }
+ }
+ },
"ssb-ref": {
"version": "http://localhost:8989/blobs/get/&wLimOD3785KVj7kBIAbjN6GH8EMhKRkcZSPrEMhdhks=.sha256",
"integrity": "sha1-XU7/xUXsD/1/wVuieCmmQLiir7o=",
@@ -1337,6 +1352,7 @@
"readable-stream": {
"version": "1.0.34",
"resolved": "http://localhost:8989/blobs/get/&0QEMlyAUePLZCW/tXOEhdYfVI4R19FBv4JyHzdW8VqY=.sha256",
+ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "http://localhost:8989/blobs/get/&pKRNq2V57ePgat5Y0m+P1kLq4JFT/VnGCPy3lRpJk5g=.sha256",
"inherits": "2.0.3",
diff --git a/package.json b/package.json
index 9a27bc1..62ec8d9 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,7 @@
"multicb": "^1.2.1",
"pull-box-stream": "^1.0.12",
"pull-cat": "^1.1.11",
+ "pull-catch": "^1.0.0",
"pull-hyperscript": "^0.2.2",
"pull-identify-filetype": "^1.1.0",
"pull-paginate": "^1.0.0",