Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: object.patch.rmLink not working #1508

Merged
merged 2 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/cli/commands/object/patch/rm-link.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/http/api/resources/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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)
}
Expand Down