From 2261874850ba715e0c322d3b2d055ac395961c36 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Fri, 10 May 2019 10:16:01 -0400 Subject: [PATCH 1/4] feat: gc --- src/repo/gc.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/repo/gc.js b/src/repo/gc.js index 27a9d3ca8..4ea6938a9 100644 --- a/src/repo/gc.js +++ b/src/repo/gc.js @@ -1,6 +1,14 @@ 'use strict' const promisify = require('promisify-es6') +const streamToValueWithTransformer = require('../utils/stream-to-value-with-transformer') + +const transform = function (res, callback) { + callback(null, res.map(r => ({ + err: r.Err, + cid: (r.Key || {})['/'] + }))) +} module.exports = (send) => { return promisify((opts, callback) => { @@ -8,9 +16,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) + }) }) } From c755ddecbbda24c36887d8665b0bad5518ee3d33 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Tue, 9 Jul 2019 10:26:52 -0400 Subject: [PATCH 2/4] fix: better repo.gc() response handling --- src/repo/gc.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/repo/gc.js b/src/repo/gc.js index 4ea6938a9..acf11c635 100644 --- a/src/repo/gc.js +++ b/src/repo/gc.js @@ -2,11 +2,12 @@ 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, - cid: (r.Key || {})['/'] + err: r.Err ? new Error(r.Err) : null, + cid: r.Key ? new CID(r.Key) : null }))) } From 0f720d13ff760154dacd39a137205554963df7b1 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Tue, 9 Jul 2019 13:30:31 -0400 Subject: [PATCH 3/4] fix: repo.gc() cid handling --- src/repo/gc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/repo/gc.js b/src/repo/gc.js index acf11c635..35d4288b0 100644 --- a/src/repo/gc.js +++ b/src/repo/gc.js @@ -7,7 +7,7 @@ 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 + cid: (r.Key || {})['/'] ? new CID(r.Key['/']) : null }))) } From ce430ffcd355e9a1f9ad29f445a8176070c3a607 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Tue, 9 Jul 2019 13:31:29 -0400 Subject: [PATCH 4/4] chore: update interface-ipfs-core --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"