提交 efb74199 作者: Łukasz Magiera

commands/block: don't use default for -f

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 6f68eac5
...@@ -132,7 +132,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. ...@@ -132,7 +132,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
cmdkit.FileArg("data", true, false, "The data to be stored as an IPFS block.").EnableStdin(), cmdkit.FileArg("data", true, false, "The data to be stored as an IPFS block.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").WithDefault(""), cmdkit.StringOption("format", "f", "cid format for blocks to be created with."),
cmdkit.StringOption("mhtype", "multihash hash function").WithDefault("sha2-256"), cmdkit.StringOption("mhtype", "multihash hash function").WithDefault("sha2-256"),
cmdkit.IntOption("mhlen", "multihash hash length").WithDefault(-1), cmdkit.IntOption("mhlen", "multihash hash length").WithDefault(-1),
}, },
...@@ -172,8 +172,8 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. ...@@ -172,8 +172,8 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
var pref cid.Prefix var pref cid.Prefix
pref.Version = 1 pref.Version = 1
format := req.Options["format"].(string) format, formatSet := req.Options["format"].(string)
if format == "" { if !formatSet {
if mhtval == mh.SHA2_256 { if mhtval == mh.SHA2_256 {
format = "v0" format = "v0"
} else { } else {
...@@ -186,7 +186,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1. ...@@ -186,7 +186,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
} }
formatval, ok := cid.Codecs[format] formatval, ok := cid.Codecs[format]
if !ok { if !ok {
res.SetError(fmt.Errorf("unrecognized format: %s", format), cmdkit.ErrNormal) res.SetError(fmt.Errorf("unrecognized format: '%s'", format), cmdkit.ErrNormal)
return return
} }
if mhtval != mh.SHA2_256 && pref.Version == 0 { if mhtval != mh.SHA2_256 && pref.Version == 0 {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论