From 514891d54a37c61cbfc49c897903f399c02f8ec0 Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Thu, 23 Aug 2018 19:17:35 +0800 Subject: [PATCH 1/9] add --name new flag when ipfs adding from stdin License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- core/commands/add.go | 4 ++++ core/coreunix/add.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/core/commands/add.go b/core/commands/add.go index a178f31e2..8c5548a5e 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -37,6 +37,7 @@ const ( progressOptionName = "progress" trickleOptionName = "trickle" wrapOptionName = "wrap-with-directory" + wrapPathName = "name" hiddenOptionName = "hidden" onlyHashOptionName = "only-hash" chunkerOptionName = "chunker" @@ -116,6 +117,7 @@ You can now check what blocks have been created by: cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."), cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."), cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."), + cmdkit.StringOption(wrapPathName, "Assign path name when use wrap-with-directory option"), cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."), cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"), cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true), @@ -181,6 +183,7 @@ You can now check what blocks have been created by: hashFunStr, _ := req.Options[hashOptionName].(string) inline, _ := req.Options[inlineOptionName].(bool) inlineLimit, _ := req.Options[inlineLimitOptionName].(int) + wrapPathName, _ := req.Options[wrapPathName].(string) // The arguments are subject to the following constraints. // @@ -287,6 +290,7 @@ You can now check what blocks have been created by: fileAdder.Silent = silent fileAdder.RawLeaves = rawblks fileAdder.NoCopy = nocopy + fileAdder.WpName = wrapPathName fileAdder.CidBuilder = prefix if inline { diff --git a/core/coreunix/add.go b/core/coreunix/add.go index ced043b9e..eeb046111 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -26,6 +26,7 @@ import ( cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid" bstore "gx/ipfs/QmcmpX42gtDv1fz24kau4wjS9hfwWj5VexWBKgGnWzsyag/go-ipfs-blockstore" mfs "gx/ipfs/QmdghKsSDa2AD1kC4qYRnVYWqZecdSBRZjeXRdhMYYhafj/go-mfs" + "strings" ) var log = logging.Logger("coreunix") @@ -83,6 +84,7 @@ type Adder struct { RawLeaves bool Silent bool Wrap bool + WpName string NoCopy bool Chunker string root ipld.Node @@ -470,6 +472,9 @@ func (adder *Adder) addFile(file files.File) error { return err } + if !strings.EqualFold(adder.WpName, "") && adder.Wrap { + return adder.addNode(dagnode, adder.WpName) + } // patch it into the root return adder.addNode(dagnode, file.FileName()) } From 19e3c127ee1f93d082ae43f2a3534adf023e1539 Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Mon, 3 Sep 2018 10:57:02 +0800 Subject: [PATCH 2/9] drop wrap check and modify parameter name License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- core/commands/add.go | 8 ++++---- core/coreunix/add.go | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index 8c5548a5e..75f65d1c5 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -37,7 +37,7 @@ const ( progressOptionName = "progress" trickleOptionName = "trickle" wrapOptionName = "wrap-with-directory" - wrapPathName = "name" + pathName = "name" hiddenOptionName = "hidden" onlyHashOptionName = "only-hash" chunkerOptionName = "chunker" @@ -117,7 +117,7 @@ You can now check what blocks have been created by: cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."), cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."), cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."), - cmdkit.StringOption(wrapPathName, "Assign path name when use wrap-with-directory option"), + cmdkit.StringOption(pathName, "Assign path name when use wrap-with-directory option"), cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."), cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"), cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true), @@ -183,7 +183,7 @@ You can now check what blocks have been created by: hashFunStr, _ := req.Options[hashOptionName].(string) inline, _ := req.Options[inlineOptionName].(bool) inlineLimit, _ := req.Options[inlineLimitOptionName].(int) - wrapPathName, _ := req.Options[wrapPathName].(string) + pathName, _ := req.Options[pathName].(string) // The arguments are subject to the following constraints. // @@ -290,7 +290,7 @@ You can now check what blocks have been created by: fileAdder.Silent = silent fileAdder.RawLeaves = rawblks fileAdder.NoCopy = nocopy - fileAdder.WpName = wrapPathName + fileAdder.Name = pathName fileAdder.CidBuilder = prefix if inline { diff --git a/core/coreunix/add.go b/core/coreunix/add.go index eeb046111..3a89aa0c5 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -26,7 +26,6 @@ import ( cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid" bstore "gx/ipfs/QmcmpX42gtDv1fz24kau4wjS9hfwWj5VexWBKgGnWzsyag/go-ipfs-blockstore" mfs "gx/ipfs/QmdghKsSDa2AD1kC4qYRnVYWqZecdSBRZjeXRdhMYYhafj/go-mfs" - "strings" ) var log = logging.Logger("coreunix") @@ -84,7 +83,7 @@ type Adder struct { RawLeaves bool Silent bool Wrap bool - WpName string + Name string NoCopy bool Chunker string root ipld.Node @@ -472,11 +471,13 @@ func (adder *Adder) addFile(file files.File) error { return err } - if !strings.EqualFold(adder.WpName, "") && adder.Wrap { - return adder.addNode(dagnode, adder.WpName) + addFileName := file.FileName() + if addFileName == "" && adder.Name != "" { + addFileName = adder.Name + adder.Name = "" } // patch it into the root - return adder.addNode(dagnode, file.FileName()) + return adder.addNode(dagnode, addFileName) } func (adder *Adder) addDir(dir files.File) error { From b61dae36f3a5a294377abce6d9f2ffe26d50c8c8 Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Wed, 5 Sep 2018 09:25:44 +0800 Subject: [PATCH 3/9] use file fullpath to judge file name License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- core/commands/add.go | 2 +- core/coreunix/add.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index 75f65d1c5..b357ee4ba 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -117,7 +117,7 @@ You can now check what blocks have been created by: cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."), cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."), cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."), - cmdkit.StringOption(pathName, "Assign path name when use wrap-with-directory option"), + cmdkit.StringOption(pathName, "Assign a name if the file source is stdin."), cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."), cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"), cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true), diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 3a89aa0c5..d3ac72d67 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -472,7 +472,7 @@ func (adder *Adder) addFile(file files.File) error { } addFileName := file.FileName() - if addFileName == "" && adder.Name != "" { + if (file.FullPath() == "/dev/stdin" || file.FullPath() == "") && adder.Name != "" { addFileName = adder.Name adder.Name = "" } From 0f4e84def4c8807b7ba4f8196cf8941d07af259a Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Wed, 5 Sep 2018 21:50:23 +0800 Subject: [PATCH 4/9] use fileinfo.abs to judge the file stdin License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- core/coreunix/add.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/coreunix/add.go b/core/coreunix/add.go index d3ac72d67..47b766138 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -472,7 +472,8 @@ func (adder *Adder) addFile(file files.File) error { } addFileName := file.FileName() - if (file.FullPath() == "/dev/stdin" || file.FullPath() == "") && adder.Name != "" { + addFileInfo := file.(files.FileInfo) + if addFileInfo.AbsPath() == os.Stdin.Name() && adder.Name != "" { addFileName = adder.Name adder.Name = "" } From ad27614a6631aec1a32126cf951e7c3f2d560ed6 Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Thu, 6 Sep 2018 15:01:17 +0800 Subject: [PATCH 5/9] add sharness tests for --name option License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- test/sharness/t0047-add-name.sh | 76 +++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 test/sharness/t0047-add-name.sh diff --git a/test/sharness/t0047-add-name.sh b/test/sharness/t0047-add-name.sh new file mode 100755 index 000000000..f9840edfd --- /dev/null +++ b/test/sharness/t0047-add-name.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2018 Kejie Zhang +# MIT Licensed; see the LICENSE file in this repository. +# + +test_description="Test add --name" + +add_name_m='QmazHkwx6mPmmCEi1jR5YzjjQd1g5XzKfYQLzRAg7x5uUk' + +add_name_1='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93' + +add_name_2='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93 +added Qmf82PSsMpUHcrqxa69KG6Qp5yeK7K9BTizXgG3nvzWcNG ' + +add_name_3='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt +added QmZbStPUUoRr1hA9GZyKx7pyskZvCczPrf6XSK6A9HSr1i ' + +add_name_4='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt' + +. lib/test-lib.sh + +test_add_name() { + + test_expect_success "go-random-files is installed" ' + type random-files + ' + + test_expect_success "random-files generates test files" ' + random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m && + echo "$add_name_m" >expected && + ipfs add -q -r m | tail -n1 >actual && + echo $actual + test_sort_cmp expected actual + ' + + # test --name without -w + test_expect_success "ipfs add --name is correct" ' + echo "$add_name_1" >expected && + ipfs add m/4r93 --name myfile.txt >actual + test_sort_cmp expected actual + ' + + # test --name with -w + test_expect_success "ipfs add -w --name is correct" ' + echo "$add_name_2" >expected && + ipfs add m/4r93 -w --name myfile.txt >actual + test_sort_cmp expected actual + ' + + # test --name with -w and cat + test_expect_success "cat file | ipfs add -w --name is correct" ' + echo "$add_name_3" >expected && + cat m/4r93 | ipfs add -w --name myfile.txt >actual + test_sort_cmp expected actual + ' + + # test --name with cat but without -w + test_expect_success "cat file | ipfs add --name is correct" ' + echo "$add_name_4" >expected && + cat m/4r93 | ipfs add --name myfile.txt >actual + test_sort_cmp expected actual + ' +} + +test_init_ipfs + +test_add_name + +test_launch_ipfs_daemon + +test_add_name + +test_kill_ipfs_daemon + +test_done From 76e8190a382efdbad882446d022ce37881b93f4a Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Thu, 6 Sep 2018 21:26:43 +0800 Subject: [PATCH 6/9] drop --name test file and update test case License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- cmd/ipfs/daemon.go | 6 +-- test/sharness/t0040-add-and-cat.sh | 21 +++++++++ test/sharness/t0047-add-name.sh | 76 ------------------------------ 3 files changed, 24 insertions(+), 79 deletions(-) delete mode 100755 test/sharness/t0047-add-name.sh diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 128efc1aa..4e4e9e980 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -287,9 +287,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment // Start assembling node config ncfg := &core.BuildCfg{ - Repo: repo, - Permanent: true, // It is temporary way to signify that node is permanent - Online: !offline, + Repo: repo, + Permanent: true, // It is temporary way to signify that node is permanent + Online: !offline, DisableEncryptedConnections: unencrypted, ExtraOpts: map[string]bool{ "pubsub": pubsub, diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index bd60140f5..c3e8b3851 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -184,6 +184,27 @@ test_add_cat_file() { test_expect_success "make sure it looks good" ' test_cmp zero-length-file zero-length-file_out ' + + test_expect_success "ipfs add --name" ' + HASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && + echo "IPFS" | ipfs add --name file.txt > actual && + echo "added $HASH file.txt" > expected && + test_cmp expected actual + ' + + test_expect_success "ipfs add --name -w" ' + HASH1="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && + echo "IPFS" | ipfs add -w --name file.txt | head -n1> actual && + echo "added $HASH1 file.txt" > expected && + test_cmp expected actual + ' + + test_expect_success "ipfs cat with name" ' + HASH=$(echo "IPFS" | ipfs add -w --name file.txt -Q) && + ipfs cat /ipfs/$HASH/file.txt > expected && + echo "IPFS" > actual && + test_cmp expected actual + ' } test_add_cat_5MB() { diff --git a/test/sharness/t0047-add-name.sh b/test/sharness/t0047-add-name.sh deleted file mode 100755 index f9840edfd..000000000 --- a/test/sharness/t0047-add-name.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2018 Kejie Zhang -# MIT Licensed; see the LICENSE file in this repository. -# - -test_description="Test add --name" - -add_name_m='QmazHkwx6mPmmCEi1jR5YzjjQd1g5XzKfYQLzRAg7x5uUk' - -add_name_1='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93' - -add_name_2='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93 -added Qmf82PSsMpUHcrqxa69KG6Qp5yeK7K9BTizXgG3nvzWcNG ' - -add_name_3='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt -added QmZbStPUUoRr1hA9GZyKx7pyskZvCczPrf6XSK6A9HSr1i ' - -add_name_4='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt' - -. lib/test-lib.sh - -test_add_name() { - - test_expect_success "go-random-files is installed" ' - type random-files - ' - - test_expect_success "random-files generates test files" ' - random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m && - echo "$add_name_m" >expected && - ipfs add -q -r m | tail -n1 >actual && - echo $actual - test_sort_cmp expected actual - ' - - # test --name without -w - test_expect_success "ipfs add --name is correct" ' - echo "$add_name_1" >expected && - ipfs add m/4r93 --name myfile.txt >actual - test_sort_cmp expected actual - ' - - # test --name with -w - test_expect_success "ipfs add -w --name is correct" ' - echo "$add_name_2" >expected && - ipfs add m/4r93 -w --name myfile.txt >actual - test_sort_cmp expected actual - ' - - # test --name with -w and cat - test_expect_success "cat file | ipfs add -w --name is correct" ' - echo "$add_name_3" >expected && - cat m/4r93 | ipfs add -w --name myfile.txt >actual - test_sort_cmp expected actual - ' - - # test --name with cat but without -w - test_expect_success "cat file | ipfs add --name is correct" ' - echo "$add_name_4" >expected && - cat m/4r93 | ipfs add --name myfile.txt >actual - test_sort_cmp expected actual - ' -} - -test_init_ipfs - -test_add_name - -test_launch_ipfs_daemon - -test_add_name - -test_kill_ipfs_daemon - -test_done From 9898ba9309f674827a7ecf3f9a04c7a45c45fb36 Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Fri, 7 Sep 2018 00:28:19 +0800 Subject: [PATCH 7/9] update test and do not overwrite in sharness test License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- cmd/ipfs/daemon.go | 6 +++--- test/sharness/t0040-add-and-cat.sh | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 4e4e9e980..128efc1aa 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -287,9 +287,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment // Start assembling node config ncfg := &core.BuildCfg{ - Repo: repo, - Permanent: true, // It is temporary way to signify that node is permanent - Online: !offline, + Repo: repo, + Permanent: true, // It is temporary way to signify that node is permanent + Online: !offline, DisableEncryptedConnections: unencrypted, ExtraOpts: map[string]bool{ "pubsub": pubsub, diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index c3e8b3851..06e298786 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -186,22 +186,22 @@ test_add_cat_file() { ' test_expect_success "ipfs add --name" ' - HASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && + NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && echo "IPFS" | ipfs add --name file.txt > actual && - echo "added $HASH file.txt" > expected && + echo "added $NAMEHASH file.txt" > expected && test_cmp expected actual ' test_expect_success "ipfs add --name -w" ' - HASH1="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && + NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && echo "IPFS" | ipfs add -w --name file.txt | head -n1> actual && - echo "added $HASH1 file.txt" > expected && + echo "added $NAMEHASH file.txt" > expected && test_cmp expected actual ' test_expect_success "ipfs cat with name" ' - HASH=$(echo "IPFS" | ipfs add -w --name file.txt -Q) && - ipfs cat /ipfs/$HASH/file.txt > expected && + NAMEHASH=$(echo "IPFS" | ipfs add -w --name file.txt -Q) && + ipfs cat /ipfs/$NAMEHASH/file.txt > expected && echo "IPFS" > actual && test_cmp expected actual ' From 7de83f25b2d50fc53bda1344b4f8efdefc4d761d Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Wed, 12 Sep 2018 05:54:54 +0800 Subject: [PATCH 8/9] add type assertion checked License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- core/coreunix/add.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 47b766138..04d79ac65 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -472,10 +472,12 @@ func (adder *Adder) addFile(file files.File) error { } addFileName := file.FileName() - addFileInfo := file.(files.FileInfo) - if addFileInfo.AbsPath() == os.Stdin.Name() && adder.Name != "" { - addFileName = adder.Name - adder.Name = "" + addFileInfo, ok := file.(files.FileInfo) + if ok { + if addFileInfo.AbsPath() == os.Stdin.Name() && adder.Name != "" { + addFileName = adder.Name + adder.Name = "" + } } // patch it into the root return adder.addNode(dagnode, addFileName) From b7ea4bfc2a2c3b864d688c108245a3429029e185 Mon Sep 17 00:00:00 2001 From: Kejie Zhang <601172892@qq.com> Date: Wed, 12 Sep 2018 05:55:49 +0800 Subject: [PATCH 9/9] modify command name and update the test License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com> --- core/commands/add.go | 6 +++--- test/sharness/t0040-add-and-cat.sh | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index b357ee4ba..1660c1256 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -37,7 +37,7 @@ const ( progressOptionName = "progress" trickleOptionName = "trickle" wrapOptionName = "wrap-with-directory" - pathName = "name" + stdinPathName = "stdin-name" hiddenOptionName = "hidden" onlyHashOptionName = "only-hash" chunkerOptionName = "chunker" @@ -117,7 +117,7 @@ You can now check what blocks have been created by: cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."), cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."), cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."), - cmdkit.StringOption(pathName, "Assign a name if the file source is stdin."), + cmdkit.StringOption(stdinPathName, "Assign a name if the file source is stdin."), cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."), cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"), cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true), @@ -183,7 +183,7 @@ You can now check what blocks have been created by: hashFunStr, _ := req.Options[hashOptionName].(string) inline, _ := req.Options[inlineOptionName].(bool) inlineLimit, _ := req.Options[inlineLimitOptionName].(int) - pathName, _ := req.Options[pathName].(string) + pathName, _ := req.Options[stdinPathName].(string) // The arguments are subject to the following constraints. // diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index 06e298786..0977c3289 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -185,22 +185,22 @@ test_add_cat_file() { test_cmp zero-length-file zero-length-file_out ' - test_expect_success "ipfs add --name" ' + test_expect_success "ipfs add --stdin-name" ' NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && - echo "IPFS" | ipfs add --name file.txt > actual && + echo "IPFS" | ipfs add --stdin-name file.txt > actual && echo "added $NAMEHASH file.txt" > expected && test_cmp expected actual ' - test_expect_success "ipfs add --name -w" ' + test_expect_success "ipfs add --stdin-name -w" ' NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && - echo "IPFS" | ipfs add -w --name file.txt | head -n1> actual && + echo "IPFS" | ipfs add -w --stdin-name file.txt | head -n1> actual && echo "added $NAMEHASH file.txt" > expected && test_cmp expected actual ' - test_expect_success "ipfs cat with name" ' - NAMEHASH=$(echo "IPFS" | ipfs add -w --name file.txt -Q) && + test_expect_success "ipfs cat with stdin-name" ' + NAMEHASH=$(echo "IPFS" | ipfs add -w --stdin-name file.txt -Q) && ipfs cat /ipfs/$NAMEHASH/file.txt > expected && echo "IPFS" > actual && test_cmp expected actual