diff --git a/package.json b/package.json index d9b58aa83..cdd0ff456 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "cross-env": "^5.2.0", "dirty-chai": "^2.0.1", "go-ipfs-dep": "~0.4.21", - "interface-ipfs-core": "~0.105.0", + "interface-ipfs-core": "~0.106.0", "ipfsd-ctl": "~0.43.0", "nock": "^10.0.2", "stream-equal": "^1.1.1" diff --git a/src/repo/gc.js b/src/repo/gc.js index 27a9d3ca8..35d4288b0 100644 --- a/src/repo/gc.js +++ b/src/repo/gc.js @@ -1,6 +1,15 @@ 'use strict' const promisify = require('promisify-es6') +const streamToValueWithTransformer = require('../utils/stream-to-value-with-transformer') +const CID = require('cids') + +const transform = function (res, callback) { + callback(null, res.map(r => ({ + err: r.Err ? new Error(r.Err) : null, + cid: (r.Key || {})['/'] ? new CID(r.Key['/']) : null + }))) +} module.exports = (send) => { return promisify((opts, callback) => { @@ -8,9 +17,17 @@ module.exports = (send) => { callback = opts opts = {} } - send({ + + const request = { path: 'repo/gc', qs: opts - }, callback) + } + send(request, (err, result) => { + if (err) { + return callback(err) + } + + streamToValueWithTransformer(result, transform, callback) + }) }) }