Skip to content

Commit cbf9156

Browse files
committed
fix(unixfsnode): have reifier add path selection to normal nodes
have reifier add path selection to all protobuf nodes, even ones that are not unixfs
1 parent 67a7e38 commit cbf9156

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

reification.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ func Reify(ctx context.Context, maybePBNodeRoot ipld.Node, lsys *ipld.LinkSystem
3434
}
3535
if !pbNode.FieldData().Exists() {
3636
// no data field, therefore, not UnixFS
37-
return pbNode, nil
37+
return defaultReifier(ctx, pbNode, lsys)
3838
}
3939
data, err := data.DecodeUnixFSData(pbNode.Data.Must().Bytes())
4040
if err != nil {
4141
// we could not decode the UnixFS data, therefore, not UnixFS
42-
return pbNode, nil
42+
return defaultReifier(ctx, pbNode, lsys)
4343
}
4444
builder, ok := reifyFuncs[data.FieldDataType().Int()]
4545
if !ok {
@@ -54,3 +54,9 @@ var reifyFuncs = map[int64]reifyTypeFunc{
5454
data.Data_Directory: directory.NewUnixFSBasicDir,
5555
data.Data_HAMTShard: hamt.NewUnixFSHAMTShard,
5656
}
57+
58+
// treat non-unixFS nodes like directories -- allow them to lookup by link
59+
// TODO: Make this a separate node as directors gain more functionality
60+
func defaultReifier(context.Context, dagpb.PBNode, *ipld.LinkSystem) (ipld.Node, error) {
61+
return &_UnixFSBasicDir{_substrate: substrate}, nil
62+
}

0 commit comments

Comments
 (0)