Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
GC endpoint (#992)
Browse files Browse the repository at this point in the history
* feat: gc

* fix: better repo.gc() response handling

* fix: repo.gc() cid handling

* chore: update interface-ipfs-core
  • Loading branch information
dirkmc authored and Alan Shaw committed Jul 10, 2019
1 parent a74b8f7 commit 63d2125
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 19 additions & 2 deletions src/repo/gc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
'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) => {
if (typeof (opts) === 'function') {
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)
})
})
}

0 comments on commit 63d2125

Please sign in to comment.