diff --git a/core/commands/add.go b/core/commands/add.go index 90861302551..73491c03b44 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -288,6 +288,10 @@ See 'dag export' and 'dag import' for more information. return fmt.Errorf("%s and %s options are not compatible", onlyHashOptionName, toFilesOptionName) } + if wrap && toFilesSet { + return fmt.Errorf("%s and %s options are not compatible", wrapOptionName, toFilesOptionName) + } + hashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)] if !ok { return fmt.Errorf("unrecognized hash function: %q", strings.ToLower(hashFunStr)) @@ -373,6 +377,11 @@ See 'dag export' and 'dag import' for more information. // creating MFS pointers when optional --to-files is set if toFilesSet { + if addit.Name() == "" { + errCh <- fmt.Errorf("%s: cannot add unnamed files to MFS", toFilesOptionName) + return + } + if toFilesStr == "" { toFilesStr = "/" } diff --git a/docs/changelogs/v0.33.md b/docs/changelogs/v0.33.md index a5d8ef2ef34..1adf16dd0bb 100644 --- a/docs/changelogs/v0.33.md +++ b/docs/changelogs/v0.33.md @@ -6,6 +6,9 @@ - [Overview](#overview) - [๐Ÿ”ฆ Highlights](#-highlights) + - [Bitswap improvements from Boxo](#bitswap-improvements-from-boxo) + - [Using default `libp2p_rcmgr` metrics](#using-default-libp2p_rcmgr--metrics) + - [`ipfs add --to-files` no longer works with `--wrap`](#ipfs-add---to-files-no-longer-works-with---wrap) - [๐Ÿ“ฆ๏ธ Dependency updates](#-dependency-updates) - [๐Ÿ“ Changelog](#-changelog) - [๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributors](#-contributors) @@ -24,6 +27,10 @@ Bespoke rcmgr metrics [were removed](https://github.com/ipfs/kubo/pull/9947), Ku This makes it easier to compare Kubo with custom implementations based on go-libp2p. If you depended on removed ones, please fill an issue to add them to the upstream [go-libp2p](https://github.com/libp2p/go-libp2p). +#### `ipfs add --to-files` no longer works with `--wrap` + +Onboarding files and directories with `ipfs add --to-files` now requires non-empty names. due to this, The `--to-files` and `--wrap` options are now mutually exclusive ([#10612](https://github.com/ipfs/kubo/issues/10612)). + #### ๐Ÿ“ฆ๏ธ Dependency updates - update `boxo` to [v0.24.TODO](https://github.com/ipfs/boxo/releases/tag/v0.24.TODO) diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index 142ab8ec18c..c7232bedd8c 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -355,10 +355,10 @@ test_add_cat_file() { test_cmp expected actual ' - test_must_fail "ipfs add with multiple files of same name but different dirs fails" ' + test_expect_success "ipfs add with multiple files of same name but different dirs fails" ' mkdir -p mountdir/same-file/ && cp mountdir/hello.txt mountdir/same-file/hello.txt && - ipfs add mountdir/hello.txt mountdir/same-file/hello.txt >actual && + test_expect_code 1 ipfs add mountdir/hello.txt mountdir/same-file/hello.txt >actual && rm mountdir/same-file/hello.txt && rmdir mountdir/same-file ' @@ -469,6 +469,15 @@ test_add_cat_file() { ipfs files rm -r --force /mfs ' + # confirm -w and --to-files are exclusive + # context: https://github.com/ipfs/kubo/issues/10611 + test_expect_success "ipfs add -r -w dir --to-files /mfs/subdir5/ errors (-w and --to-files are exclusive)" ' + ipfs files mkdir -p /mfs/subdir5 && + test_expect_code 1 ipfs add -r -w test --to-files /mfs/subdir5/ >actual 2>&1 && + test_should_contain "Error" actual && + ipfs files rm -r --force /mfs + ' + } test_add_cat_5MB() {