-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
core/commands/add: Change add() to only accept a single reader #1127
Conversation
The change to an array of readers comes from e096060 (refactor(core/commands2/add) split loop, 2014-11-06), where it's used to setup readers for each path in the argument list. However, since 6faeee8 (cmds2/add: temp fix for -r. horrible hack, 2014-11-11) the argument looping moved outside of add() and into Run(), so we can drop the multiple-reader support from add(). Adding a file can create multiple nodes (e.g. the splitter can chunk the file into several blocks), but: 1. we were only appending a single node per reader to our returned list, and 2. we are only using the final node in that returned list, so this commit also adjusts add() to return a single node reference instead on an array of nodes.
you need to make sure your local repo for go-ipfs is properly placed within your |
On Thu, Apr 23, 2015 at 10:56:23AM -0700, Jeromy Johnson wrote:
It's at $GOPATH/src/github.com/ipfs/go-ipfs, which seems right to me. |
Hmm, there are some very similar looking functions in
core/coreunix/add.go. Should I be updating them too? Removing the
versions in core/commands/add.go and using the coreunix versions
instead? Removing the versions in coreunix and using the commands
versions wherever the coreunix versions are being used? How are these
pieces supposed to fit together?
|
31ed7f1
to
641c20b
Compare
Catch up with core/commands/add.go.
On Thu, Apr 23, 2015 at 10:56:23AM -0700, Jeromy Johnson wrote:
Blowing away my GOPATH and starting over with: $ go get github.com/ipfs/go-ipfs has things working. So I must have tangled up my GOPATH with my |
@wking I really think we should try and reduce code duplication between core/commands/add and core/coreunix/add. exporting the functions from coreunix should be fine IMO |
On Fri, Apr 24, 2015 at 10:24:25AM -0700, Jeromy Johnson wrote:
coreunix.add is so low-level. I think we want to shift the whole of |
On Fri, Apr 24, 2015 at 10:57:12AM -0700, W. Trevor King wrote:
Looks like explicit nils or alternative function names are the way to func addFile(n _core.IpfsNode, file files.File, out chan interface{}, progress bool, wrap bool) (_dag.Node, error) or: func addFile(n *core.IpfsNode, file files.File) We already have coreunix.AddWrapped: func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, *merkledag.Node, error) but that's not going to work well with metadata. I think we should func addTree(n _core.IpfsNode, file files.File, out chan interface{}) (_dag.Node, error) with sufficient details sent down the out channel to attach a progress |
I think that interface feels a little closer to what we want.. I'll think about it some. maybe @jbenet has some ideas too. We really want to fix the entire add command, its not pretty right now. |
This is internal code to the add command, so i don't care much. This seems like reduction of complexity, and 👍 LGTM. (to be clear, in the core/shell case though -- the api we export to users -- it should match the cli as close as possible. so |
core/commands/add: Change add() to only accept a single reader
The change to an array of readers comes from e096060
(refactor(core/commands2/add) split loop, 2014-11-06), where it's used
to setup readers for each path in the argument list. However, since
6faeee8 (cmds2/add: temp fix for -r. horrible hack, 2014-11-11) the
argument looping moved outside of add() and into Run(), so we can drop
the multiple-reader support from add().
Adding a file can create multiple nodes (e.g. the splitter can chunk
the file into several blocks), but:
list, and
so this commit also adjusts add() to return a single node reference
instead on an array of nodes.
I'm having trouble running the test suite locally:
so someone more familiar with building and running the test suite
should put this through its paces before merging.