diff --git a/src/cli/commands/object/patch/rm-link.js b/src/cli/commands/object/patch/rm-link.js index cac1666ce3..dde69c30f8 100644 --- a/src/cli/commands/object/patch/rm-link.js +++ b/src/cli/commands/object/patch/rm-link.js @@ -1,6 +1,5 @@ 'use strict' -const DAGLink = require('ipld-dag-pb').DAGLink const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') @@ -14,12 +13,7 @@ module.exports = { builder: {}, handler (argv) { - // TODO rmLink should support removing by name and/or multihash - // without having to know everything, which in fact it does, however, - // since it expectes a DAGLink type, we have to pass some fake size and - // hash. - const link = new DAGLink(argv.link, 1, 'Qm') - argv.ipfs.object.patch.rmLink(argv.root, link, { + argv.ipfs.object.patch.rmLink(argv.root, { name: argv.link }, { enc: 'base58' }, (err, node) => { if (err) { diff --git a/src/core/components/pin-set.js b/src/core/components/pin-set.js index 1c816d993c..d100b85311 100644 --- a/src/core/components/pin-set.js +++ b/src/core/components/pin-set.js @@ -168,7 +168,7 @@ exports = module.exports = function (dag) { function storeChild (err, child, binIdx, cb) { if (err) { return cb(err) } - const opts = { cid: new CID(child._multihash), preload: false } + const opts = { cid: new CID(child.multihash), preload: false } dag.put(child, opts, err => { if (err) { return cb(err) } fanoutLinks[binIdx] = new DAGLink('', child.size, child.multihash) diff --git a/src/http/api/resources/object.js b/src/http/api/resources/object.js index 16f5db9c8d..9f9e7f2e32 100644 --- a/src/http/api/resources/object.js +++ b/src/http/api/resources/object.js @@ -520,7 +520,7 @@ exports.patchRmLink = { if (!request.query.arg[1]) { return reply({ - Message: 'cannot create link with no name!', + Message: 'cannot remove link with no name!', Code: 0 }).code(500).takeover() } @@ -545,11 +545,11 @@ exports.patchRmLink = { const link = request.pre.args.link const ipfs = request.server.app.ipfs - ipfs.object.patch.rmLink(root, link, (err, node) => { + ipfs.object.patch.rmLink(root, { name: link }, (err, node) => { if (err) { log.error(err) return reply({ - Message: 'Failed to add link to object: ' + err, + Message: 'Failed to remove link from object: ' + err, Code: 0 }).code(500) } diff --git a/test/core/pin-set.js b/test/core/pin-set.js index 33b50ad144..64b8fb1389 100644 --- a/test/core/pin-set.js +++ b/test/core/pin-set.js @@ -31,7 +31,7 @@ function createNodes (num, callback) { const items = [] for (let i = 0; i < num; i++) { items.push(cb => - createNode(String(i), (err, node) => cb(err, node._multihash)) + createNode(String(i), (err, node) => cb(err, node.multihash)) ) } @@ -73,7 +73,7 @@ describe('pinSet', function () { createNode('data', (err, node) => { expect(err).to.not.exist() - const nodeHash = node._multihash + const nodeHash = node.multihash pinSet.storeSet([nodeHash], (err, rootNode) => { expect(err).to.not.exist() const node = rootNode.toJSON()