From 680c80a9ff4511aca282b9562f2ab869ae122348 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 27 Sep 2021 12:50:26 -0400 Subject: [PATCH] fuse: load unixfs adls as their dagpb substrates (cherry picked from commit 85e30b9b3635a40781c3b8e99ca40978c514146e) --- docs/examples/go-ipfs-as-a-library/go.sum | 3 ++- fuse/readonly/readonly_unix.go | 9 ++++++++- go.mod | 2 +- go.sum | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/examples/go-ipfs-as-a-library/go.sum b/docs/examples/go-ipfs-as-a-library/go.sum index b4850648876..69491d31cc7 100644 --- a/docs/examples/go-ipfs-as-a-library/go.sum +++ b/docs/examples/go-ipfs-as-a-library/go.sum @@ -545,8 +545,9 @@ github.com/ipfs/go-unixfs v0.1.0/go.mod h1:lysk5ELhOso8+Fed9U1QTGey2ocsfaZ18h0NC github.com/ipfs/go-unixfs v0.2.4/go.mod h1:SUdisfUjNoSDzzhGVxvCL9QO/nKdwXdr+gbMUdqcbYw= github.com/ipfs/go-unixfs v0.2.5 h1:irj/WzIcgTBay48mSMUYDbKlIzIocXWcuUUsi5qOMOE= github.com/ipfs/go-unixfs v0.2.5/go.mod h1:SUdisfUjNoSDzzhGVxvCL9QO/nKdwXdr+gbMUdqcbYw= -github.com/ipfs/go-unixfsnode v1.1.2 h1:aTsCdhwU0F4dMShMwYGroAj4v4EzSONLdoENebvTRb0= github.com/ipfs/go-unixfsnode v1.1.2/go.mod h1:5dcE2x03pyjHk4JjamXmunTMzz+VUtqvPwZjIEkfV6s= +github.com/ipfs/go-unixfsnode v1.1.3 h1:IyqJBGIEvcHvll1wDDVIHOEVXnE+IH6tjzTWpZ6kGiI= +github.com/ipfs/go-unixfsnode v1.1.3/go.mod h1:ZZxUM5wXBC+G0Co9FjrYTOm+UlhZTjxLfRYdWY9veZ4= github.com/ipfs/go-verifcid v0.0.1 h1:m2HI7zIuR5TFyQ1b79Da5N9dnnCP1vcu2QqawmWlK2E= github.com/ipfs/go-verifcid v0.0.1/go.mod h1:5Hrva5KBeIog4A+UpqlaIU+DEstipcJYQQZc0g37pY0= github.com/ipfs/interface-go-ipfs-core v0.4.0/go.mod h1:UJBcU6iNennuI05amq3FQ7g0JHUkibHFAfhfUIy927o= diff --git a/fuse/readonly/readonly_unix.go b/fuse/readonly/readonly_unix.go index dbdee5190bf..85d5e1a6ba3 100644 --- a/fuse/readonly/readonly_unix.go +++ b/fuse/readonly/readonly_unix.go @@ -21,6 +21,7 @@ import ( "github.com/ipfs/go-path/resolver" ft "github.com/ipfs/go-unixfs" uio "github.com/ipfs/go-unixfs/io" + ipldprime "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" ) @@ -89,7 +90,13 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) { var fnd ipld.Node switch cidLnk.Cid.Prefix().Codec { case cid.DagProtobuf: - fnd, err = mdag.ProtoNodeConverter(blk, nd) + adl, ok := nd.(ipldprime.ADL) + if ok { + substrate := adl.Substrate() + fnd, err = mdag.ProtoNodeConverter(blk, substrate) + } else { + fnd, err = mdag.ProtoNodeConverter(blk, nd) + } case cid.Raw: fnd, err = mdag.RawNodeConverter(blk, nd) default: diff --git a/go.mod b/go.mod index 1f3bf2c0bd4..5da91c59674 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/ipfs/go-path v0.1.2 github.com/ipfs/go-pinning-service-http-client v0.1.0 github.com/ipfs/go-unixfs v0.2.5 - github.com/ipfs/go-unixfsnode v1.1.2 + github.com/ipfs/go-unixfsnode v1.1.3 github.com/ipfs/go-verifcid v0.0.1 github.com/ipfs/interface-go-ipfs-core v0.5.1 github.com/ipfs/tar-utils v0.0.1 diff --git a/go.sum b/go.sum index 3ffc36ab6a4..d8517932a6a 100644 --- a/go.sum +++ b/go.sum @@ -560,8 +560,9 @@ github.com/ipfs/go-unixfs v0.1.0/go.mod h1:lysk5ELhOso8+Fed9U1QTGey2ocsfaZ18h0NC github.com/ipfs/go-unixfs v0.2.4/go.mod h1:SUdisfUjNoSDzzhGVxvCL9QO/nKdwXdr+gbMUdqcbYw= github.com/ipfs/go-unixfs v0.2.5 h1:irj/WzIcgTBay48mSMUYDbKlIzIocXWcuUUsi5qOMOE= github.com/ipfs/go-unixfs v0.2.5/go.mod h1:SUdisfUjNoSDzzhGVxvCL9QO/nKdwXdr+gbMUdqcbYw= -github.com/ipfs/go-unixfsnode v1.1.2 h1:aTsCdhwU0F4dMShMwYGroAj4v4EzSONLdoENebvTRb0= github.com/ipfs/go-unixfsnode v1.1.2/go.mod h1:5dcE2x03pyjHk4JjamXmunTMzz+VUtqvPwZjIEkfV6s= +github.com/ipfs/go-unixfsnode v1.1.3 h1:IyqJBGIEvcHvll1wDDVIHOEVXnE+IH6tjzTWpZ6kGiI= +github.com/ipfs/go-unixfsnode v1.1.3/go.mod h1:ZZxUM5wXBC+G0Co9FjrYTOm+UlhZTjxLfRYdWY9veZ4= github.com/ipfs/go-verifcid v0.0.1 h1:m2HI7zIuR5TFyQ1b79Da5N9dnnCP1vcu2QqawmWlK2E= github.com/ipfs/go-verifcid v0.0.1/go.mod h1:5Hrva5KBeIog4A+UpqlaIU+DEstipcJYQQZc0g37pY0= github.com/ipfs/interface-go-ipfs-core v0.4.0/go.mod h1:UJBcU6iNennuI05amq3FQ7g0JHUkibHFAfhfUIy927o=