1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 03:19:47 +08:00

Add global --cid-base option and enable it for most commands.

This does it on ther server side for most commands.

This also adds a global --output-cidv1 option.

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
This commit is contained in:
Kevin Atkinson
2018-11-22 04:16:45 -05:00
parent 5512ad53c4
commit b22275fb66
28 changed files with 793 additions and 168 deletions

View File

@ -82,6 +82,14 @@ Resolve the value of an IPFS DAG path:
name := req.Arguments[0]
recursive, _ := req.Options[resolveRecursiveOptionName].(bool)
enc, err := cmdenv.GetCidEncoder(req)
if err != nil {
return err
}
if !cmdenv.CidBaseDefined(req) {
enc, _ = cmdenv.CidEncoderFromPath(enc, name)
}
// the case when ipns is resolved step by step
if strings.HasPrefix(name, "/ipns/") && !recursive {
rc, rcok := req.Options[resolveDhtRecordCountOptionName].(uint)
@ -128,7 +136,7 @@ Resolve the value of an IPFS DAG path:
return fmt.Errorf("found non-link at given path")
}
return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path("/" + rp.Namespace() + "/" + rp.Cid().String())})
return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path("/" + rp.Namespace() + "/" + enc.Encode(rp.Cid()))})
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, rp *ncmd.ResolvedPath) error {