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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user