Commit b5618106 authored by Overbool's avatar Overbool Committed by Lucas Molas

fix(resolve): replace switch with if

parent 3512ccf8
...@@ -13,16 +13,15 @@ import ( ...@@ -13,16 +13,15 @@ import (
// ResolveUnixfsOnce resolves a single hop of a path through a graph in a // ResolveUnixfsOnce resolves a single hop of a path through a graph in a
// unixfs context. This includes handling traversing sharded directories. // unixfs context. This includes handling traversing sharded directories.
func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error) { func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error) {
switch nd := nd.(type) { pn, ok := nd.(*dag.ProtoNode)
case *dag.ProtoNode: if ok {
fsn, err := ft.FSNodeFromBytes(nd.Data()) fsn, err := ft.FSNodeFromBytes(pn.Data())
if err != nil { if err != nil {
// Not a unixfs node, use standard object traversal code // Not a unixfs node, use standard object traversal code
return nd.ResolveLink(names) return nd.ResolveLink(names)
} }
switch fsn.Type() { if fsn.Type() == ft.THAMTShard {
case ft.THAMTShard:
rods := dag.NewReadOnlyDagService(ds) rods := dag.NewReadOnlyDagService(ds)
s, err := hamt.NewHamtFromDag(rods, nd) s, err := hamt.NewHamtFromDag(rods, nd)
if err != nil { if err != nil {
...@@ -37,5 +36,6 @@ func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, na ...@@ -37,5 +36,6 @@ func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, na
return out, names[1:], nil return out, names[1:], nil
} }
} }
return nd.ResolveLink(names) return nd.ResolveLink(names)
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment