1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 03:19:47 +08:00

Fix some weird code in core/coreunix/add.go

Code was just weird. I think it looks better now.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This commit is contained in:
Hector Sanjuan
2018-08-09 00:48:14 +02:00
parent 672591972c
commit de72087df3

View File

@ -201,7 +201,8 @@ func (adder *Adder) Finalize() (ipld.Node, error) {
return nil, err
}
var root mfs.FSNode
root = mr.GetDirectory()
rootdir := mr.GetDirectory()
root = rootdir
err = root.Flush()
if err != nil {
@ -210,7 +211,7 @@ func (adder *Adder) Finalize() (ipld.Node, error) {
var name string
if !adder.Wrap {
children, err := root.(*mfs.Directory).ListNames(adder.ctx)
children, err := rootdir.ListNames(adder.ctx)
if err != nil {
return nil, err
}
@ -219,16 +220,9 @@ func (adder *Adder) Finalize() (ipld.Node, error) {
return nil, fmt.Errorf("expected at least one child dir, got none")
}
// Replace root with the first child
name = children[0]
mr, err := adder.mfsRoot()
if err != nil {
return nil, err
}
dir := mr.GetDirectory()
root, err = dir.Child(name)
root, err = rootdir.Child(name)
if err != nil {
return nil, err
}