@cryptotaxi247 / kubo / commits / 271349030

commands(pin update): return resolved CIDs instead of paths

fixes #6269 License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Apr 29, 2019 at 13:38 UTC 2713490304be053dea135994d6911bb261a2a59a
1 file changed +15 -3
core/commands/pin.go
+15 -3
@@ -406,17 +406,29 @@ new pin and removing the old one.
406 return err
407 }
408
409 + enc, err := cmdenv.GetCidEncoder(req)
410 + if err != nil {
411 + return err
412 + }
413 +
414 unpin, _ := req.Options[pinUnpinOptionName].(bool)
415
411 - from := path.New(req.Arguments[0])
412 - to := path.New(req.Arguments[1])
416 + // Resolve the paths ahead of time so we can return the actual CIDs
417 + from, err := api.ResolvePath(req.Context, path.New(req.Arguments[0]))
418 + if err != nil {
419 + return err
420 + }
421 + to, err := api.ResolvePath(req.Context, path.New(req.Arguments[1]))
422 + if err != nil {
423 + return err
424 + }
425
426 err = api.Pin().Update(req.Context, from, to, options.Pin.Unpin(unpin))
427 if err != nil {
428 return err
429 }
430
419 - return cmds.EmitOnce(res, &PinOutput{Pins: []string{from.String(), to.String()}})
431 + return cmds.EmitOnce(res, &PinOutput{Pins: []string{enc.Encode(from.Cid()), enc.Encode(to.Cid())}})
432 },
433 Encoders: cmds.EncoderMap{
434 cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinOutput) error {