aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-23 23:24:25 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-23 23:24:25 -1000
commitd10fc1c7fbc410ec0c4773902251255582e33adc (patch)
treeda43af098d4d11b857f17eaad46c1b0050c8f70d /lib/app.js
parent6dbfedff2f7246430f4e6da100bc3baed0ef4ce1 (diff)
downloadpatchfoo-d10fc1c7fbc410ec0c4773902251255582e33adc.tar.gz
patchfoo-d10fc1c7fbc410ec0c4773902251255582e33adc.zip
wip: more git
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index 4219151..1daf064 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -11,6 +11,7 @@ var Contacts = require('ssb-contact')
var About = require('./about')
var Serve = require('./serve')
var Render = require('./render')
+var Git = require('./git')
module.exports = App
@@ -41,6 +42,7 @@ function App(sbot, config) {
this.unboxMsg = this.unboxMsg.bind(this)
this.render = new Render(this, this.opts)
+ this.git = new Git(this)
}
App.prototype.go = function () {
@@ -186,6 +188,36 @@ App.prototype.pushBlob = function (id, cb) {
this.sbot.blobs.push(id, cb)
}
+App.prototype.readBlob = function (link, opts) {
+ link = u.toLink(link)
+ opts = opts || {}
+ return this.sbot.blobs.get({
+ hash: link.link,
+ size: link.size,
+ start: opts.start,
+ end: opts.end,
+ })
+}
+
+App.prototype.ensureHasBlobs = function (links, cb) {
+ var self = this
+ var done = multicb({pluck: 1})
+ links.forEach(function (link) {
+ var cb = done()
+ self.sbot.blobs.size(link.link, function (err, size) {
+ if (err) cb(err)
+ else if (size == null) cb(null, link)
+ else cb()
+ })
+ })
+ done(function (err, missingLinks) {
+ if (err) console.trace(err)
+ missingLinks = missingLinks.filter(Boolean)
+ if (missingLinks.length == 0) return cb()
+ return cb({name: 'BlobNotFoundError', links: missingLinks})
+ })
+}
+
App.prototype.getReverseNameSync = function (name) {
var id = this.reverseNameCache.get(name)
return id