@cryptotaxi247 / kubo / commits / de72087df

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>

Hector Sanjuan committed Aug 9, 2018 at 00:48 UTC de72087df319aee5ce93baf24b838075ef91487d
1 file changed +5 -11
core/coreunix/add.go
+5 -11
@@ -201,7 +201,8 @@ func (adder *Adder) Finalize() (ipld.Node, error) {
201 return nil, err
202 }
203 var root mfs.FSNode
204 - root = mr.GetDirectory()
204 + rootdir := mr.GetDirectory()
205 + root = rootdir
206
207 err = root.Flush()
208 if err != nil {
@@ -210,7 +211,7 @@ func (adder *Adder) Finalize() (ipld.Node, error) {
211
212 var name string
213 if !adder.Wrap {
213 - children, err := root.(*mfs.Directory).ListNames(adder.ctx)
214 + children, err := rootdir.ListNames(adder.ctx)
215 if err != nil {
216 return nil, err
217 }
@@ -219,16 +220,9 @@ func (adder *Adder) Finalize() (ipld.Node, error) {
220 return nil, fmt.Errorf("expected at least one child dir, got none")
221 }
222
223 + // Replace root with the first child
224 name = children[0]
223 -
224 - mr, err := adder.mfsRoot()
225 - if err != nil {
226 - return nil, err
227 - }
228 -
229 - dir := mr.GetDirectory()
230 -
231 - root, err = dir.Child(name)
225 + root, err = rootdir.Child(name)
226 if err != nil {
227 return nil, err
228 }