feat: add support for directories in GetMetadataByCID
This commit is contained in:
parent
712e216150
commit
f6e005c497
|
@ -17,6 +17,10 @@ type DirectoryMetadata struct {
|
||||||
|
|
||||||
var _ SerializableMetadata = (*DirectoryMetadata)(nil)
|
var _ SerializableMetadata = (*DirectoryMetadata)(nil)
|
||||||
|
|
||||||
|
func NewEmptyDirectoryMetadata() *DirectoryMetadata {
|
||||||
|
return &DirectoryMetadata{}
|
||||||
|
}
|
||||||
|
|
||||||
func NewDirectoryMetadata(details DirectoryMetadataDetails, directories directoryReferenceMap, files fileReferenceMap, extraMetadata ExtraMetadata) *DirectoryMetadata {
|
func NewDirectoryMetadata(details DirectoryMetadataDetails, directories directoryReferenceMap, files fileReferenceMap, extraMetadata ExtraMetadata) *DirectoryMetadata {
|
||||||
dirMetadata := &DirectoryMetadata{
|
dirMetadata := &DirectoryMetadata{
|
||||||
Details: details,
|
Details: details,
|
||||||
|
|
|
@ -306,6 +306,13 @@ func (n *NodeImpl) GetMetadataByCID(cid *encoding.CID) (md metadata.Metadata, er
|
||||||
case types.CIDTypeMetadataWebapp:
|
case types.CIDTypeMetadataWebapp:
|
||||||
md = metadata.NewEmptyWebAppMetadata()
|
md = metadata.NewEmptyWebAppMetadata()
|
||||||
|
|
||||||
|
err = msgpack.Unmarshal(bytes, md)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case types.CIDTypeDirectory:
|
||||||
|
md = metadata.NewEmptyDirectoryMetadata()
|
||||||
|
|
||||||
err = msgpack.Unmarshal(bytes, md)
|
err = msgpack.Unmarshal(bytes, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue