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 (
// ResolveUnixfsOnce resolves a single hop of a path through a graph in a
// 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) {
switch nd := nd.(type) {
case *dag.ProtoNode:
fsn, err := ft.FSNodeFromBytes(nd.Data())
pn, ok := nd.(*dag.ProtoNode)
if ok {
fsn, err := ft.FSNodeFromBytes(pn.Data())
if err != nil {
// Not a unixfs node, use standard object traversal code
return nd.ResolveLink(names)
}
switch fsn.Type() {
case ft.THAMTShard:
if fsn.Type() == ft.THAMTShard {
rods := dag.NewReadOnlyDagService(ds)
s, err := hamt.NewHamtFromDag(rods, nd)
if err != nil {
......@@ -37,5 +36,6 @@ func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, na
return out, names[1:], nil
}
}
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