Skip to content

Commit

Permalink
Merge pull request #6275 from ipfs/fix/6269-a
Browse files Browse the repository at this point in the history
commands(pin update): return resolved CIDs instead of paths
  • Loading branch information
Stebalien committed May 2, 2019
2 parents af8edb0 + 2713490 commit 5fd5d44
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,29 @@ new pin and removing the old one.
return err
}

enc, err := cmdenv.GetCidEncoder(req)
if err != nil {
return err
}

unpin, _ := req.Options[pinUnpinOptionName].(bool)

from := path.New(req.Arguments[0])
to := path.New(req.Arguments[1])
// Resolve the paths ahead of time so we can return the actual CIDs
from, err := api.ResolvePath(req.Context, path.New(req.Arguments[0]))
if err != nil {
return err
}
to, err := api.ResolvePath(req.Context, path.New(req.Arguments[1]))
if err != nil {
return err
}

err = api.Pin().Update(req.Context, from, to, options.Pin.Unpin(unpin))
if err != nil {
return err
}

return cmds.EmitOnce(res, &PinOutput{Pins: []string{from.String(), to.String()}})
return cmds.EmitOnce(res, &PinOutput{Pins: []string{enc.Encode(from.Cid()), enc.Encode(to.Cid())}})
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinOutput) error {
Expand Down

0 comments on commit 5fd5d44

Please sign in to comment.