@cryptotaxi247 / kubo / commits / 19e3c127e

drop wrap check and modify parameter name

License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com>

Kejie Zhang committed Sep 3, 2018 at 10:57 UTC 19e3c127ee1f93d082ae43f2a3534adf023e1539
2 files changed +10 -9
core/commands/add.go
+4 -4
@@ -37,7 +37,7 @@ const (
37 progressOptionName = "progress"
38 trickleOptionName = "trickle"
39 wrapOptionName = "wrap-with-directory"
40 - wrapPathName = "name"
40 + pathName = "name"
41 hiddenOptionName = "hidden"
42 onlyHashOptionName = "only-hash"
43 chunkerOptionName = "chunker"
@@ -117,7 +117,7 @@ You can now check what blocks have been created by:
117 cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
118 cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
119 cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
120 - cmdkit.StringOption(wrapPathName, "Assign path name when use wrap-with-directory option"),
120 + cmdkit.StringOption(pathName, "Assign path name when use wrap-with-directory option"),
121 cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
122 cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
123 cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
@@ -183,7 +183,7 @@ You can now check what blocks have been created by:
183 hashFunStr, _ := req.Options[hashOptionName].(string)
184 inline, _ := req.Options[inlineOptionName].(bool)
185 inlineLimit, _ := req.Options[inlineLimitOptionName].(int)
186 - wrapPathName, _ := req.Options[wrapPathName].(string)
186 + pathName, _ := req.Options[pathName].(string)
187
188 // The arguments are subject to the following constraints.
189 //
@@ -290,7 +290,7 @@ You can now check what blocks have been created by:
290 fileAdder.Silent = silent
291 fileAdder.RawLeaves = rawblks
292 fileAdder.NoCopy = nocopy
293 - fileAdder.WpName = wrapPathName
293 + fileAdder.Name = pathName
294 fileAdder.CidBuilder = prefix
295
296 if inline {
core/coreunix/add.go
+6 -5
@@ -26,7 +26,6 @@ import (
26 cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid"
27 bstore "gx/ipfs/QmcmpX42gtDv1fz24kau4wjS9hfwWj5VexWBKgGnWzsyag/go-ipfs-blockstore"
28 mfs "gx/ipfs/QmdghKsSDa2AD1kC4qYRnVYWqZecdSBRZjeXRdhMYYhafj/go-mfs"
29 - "strings"
29 )
30
31 var log = logging.Logger("coreunix")
@@ -84,7 +83,7 @@ type Adder struct {
83 RawLeaves bool
84 Silent bool
85 Wrap bool
87 - WpName string
86 + Name string
87 NoCopy bool
88 Chunker string
89 root ipld.Node
@@ -472,11 +471,13 @@ func (adder *Adder) addFile(file files.File) error {
471 return err
472 }
473
475 - if !strings.EqualFold(adder.WpName, "") && adder.Wrap {
476 - return adder.addNode(dagnode, adder.WpName)
474 + addFileName := file.FileName()
475 + if addFileName == "" && adder.Name != "" {
476 + addFileName = adder.Name
477 + adder.Name = ""
478 }
479 // patch it into the root
479 - return adder.addNode(dagnode, file.FileName())
480 + return adder.addNode(dagnode, addFileName)
481 }
482
483 func (adder *Adder) addDir(dir files.File) error {