Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Better functionality for ipfs add --to-files -w #10658

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ See 'dag export' and 'dag import' for more information.
if onlyHash && toFilesSet {
return fmt.Errorf("%s and %s options are not compatible", onlyHashOptionName, toFilesOptionName)
}

var toFilesWrap bool = false
if wrap && toFilesSet {
return fmt.Errorf("%s and %s options are not compatible", wrapOptionName, toFilesOptionName)
toFilesWrap = true
}

hashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)]
Expand Down Expand Up @@ -377,10 +377,10 @@ 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 addit.Name() == "" {
// errCh <- fmt.Errorf("%s: cannot add unnamed files to MFS", toFilesOptionName)
// return
// }

if toFilesStr == "" {
toFilesStr = "/"
Expand All @@ -405,7 +405,12 @@ See 'dag export' and 'dag import' for more information.
return
}
// if MFS destination is a dir, append filename to the dir path
toFilesDst += gopath.Base(addit.Name())
if toFilesWrap {
// pathAdded.RootCid() is like the same thing as lastHash. See lastHash below in this file.
toFilesDst += gopath.Base(pathAdded.RootCid().String())
} else {
toFilesDst += gopath.Base(addit.Name())
}
}

// error if we try to overwrite a preexisting file destination
Expand Down
4 changes: 2 additions & 2 deletions docs/changelogs/v0.33.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ New repositories initialized with `flatfs` in `Datastore.Spec` will have `sync`

The old default was overly conservative and caused performance issues in big repositories that did a lot of writes. There is usually no need to flush on every block write to disk before continuing. Setting this to false is safe as kubo will automatically flush writes to disk before and after performing critical operations like pinning. However, we still provide users with ability to set this to true to be extra-safe (at the cost of a slowdown when adding files in bulk).

#### `ipfs add --to-files` no longer works with `--wrap`
#### `ipfs add --to-files` works better 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)).
Onboarding files and directories with `ipfs add --to-files` <s>now requires non-empty names. due to this, The `--to-files`</s> and `--wrap` now adds the final/wrapped CID to MFS instead of a literal "." ([#10612](https://github.com/ipfs/kubo/issues/10612)).

#### New options for faster writes: `WriteThrough`, `BlockKeyCacheSize`, `BatchMaxNodes`, `BatchMaxSize`

Expand Down