aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
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