fix: need to use directoryReferenceSerializationMap
This commit is contained in:
parent
012c90ddae
commit
de909db84e
|
@ -1,6 +1,9 @@
|
||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import "github.com/vmihailenco/msgpack/v5"
|
import (
|
||||||
|
"github.com/emirpasic/gods/maps/linkedhashmap"
|
||||||
|
"github.com/vmihailenco/msgpack/v5"
|
||||||
|
)
|
||||||
|
|
||||||
var _ SerializableMetadata = (*DirectoryReference)(nil)
|
var _ SerializableMetadata = (*DirectoryReference)(nil)
|
||||||
|
|
||||||
|
@ -31,22 +34,22 @@ func NewDirectoryReference(created uint64, name string, encryptedWriteKey, publi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DirectoryReference) EncodeMsgpack(enc *msgpack.Encoder) error {
|
func (dr *DirectoryReference) EncodeMsgpack(enc *msgpack.Encoder) error {
|
||||||
data := map[int]interface{}{
|
dmap := &directoryReferenceSerializationMap{*linkedhashmap.New()}
|
||||||
1: dr.Name,
|
|
||||||
2: dr.Created,
|
dmap.Put(1, dr.Name)
|
||||||
3: dr.PublicKey,
|
dmap.Put(2, dr.Created)
|
||||||
4: dr.EncryptedWriteKey,
|
dmap.Put(3, dr.PublicKey)
|
||||||
}
|
dmap.Put(4, dr.EncryptedWriteKey)
|
||||||
|
|
||||||
if dr.EncryptionKey != nil {
|
if dr.EncryptionKey != nil {
|
||||||
data[5] = dr.EncryptionKey
|
dmap.Put(5, dr.EncryptionKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if dr.Ext != nil {
|
if dr.Ext != nil {
|
||||||
data[6] = dr.Ext
|
dmap.Put(6, dr.Ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
return enc.Encode(data)
|
return enc.Encode(dmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *DirectoryReference) DecodeMsgpack(dec *msgpack.Decoder) error {
|
func (dr *DirectoryReference) DecodeMsgpack(dec *msgpack.Decoder) error {
|
||||||
|
|
Loading…
Reference in New Issue