From b66bcecec258b0a2631ec338501afa9409882fe8 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 28 May 2017 18:42:44 -1000 Subject: Slice packfiles manually Support vanilla multiblob --- lib/app.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index 1daf064..8ef859f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -177,10 +177,7 @@ App.prototype.addBlob = function (cb) { done(function (err, hash, add) { cb(err, hash) }) - return pull( - hasher(hashCb), - this.sbot.blobs.add(addCb) - ) + return sink } App.prototype.pushBlob = function (id, cb) { @@ -188,15 +185,25 @@ App.prototype.pushBlob = function (id, cb) { this.sbot.blobs.push(id, cb) } -App.prototype.readBlob = function (link, opts) { +App.prototype.readBlob = function (link) { link = u.toLink(link) - opts = opts || {} return this.sbot.blobs.get({ hash: link.link, size: link.size, + }) +} + +App.prototype.readBlobSlice = function (link, opts) { + if (this.sbot.blobs.getSlice) return this.sbot.blobs.getSlice({ + hash: link.link, + size: link.size, start: opts.start, end: opts.end, }) + return pull( + this.readBlob(link), + u.pullSlice(opts.start, opts.end) + ) } App.prototype.ensureHasBlobs = function (links, cb) { -- cgit v1.2.3