refactor: change FileReference.DecodeMsgpack to use an empty map wrapper for exp and history if they were not decoded, we don't want them nil
This commit is contained in:
parent
c5fb8a2c15
commit
0e2ef0969a
|
@ -75,6 +75,9 @@ func (fr *FileReference) DecodeMsgpack(dec *msgpack.Decoder) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasExt := false
|
||||||
|
hasHistory := false
|
||||||
|
|
||||||
for i := 0; i < mapLen; i++ {
|
for i := 0; i < mapLen; i++ {
|
||||||
key, err := dec.DecodeInt8()
|
key, err := dec.DecodeInt8()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -114,6 +117,8 @@ func (fr *FileReference) DecodeMsgpack(dec *msgpack.Decoder) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasExt = true
|
||||||
case int8(8):
|
case int8(8):
|
||||||
historyDataLen, err := dec.DecodeMapLen()
|
historyDataLen, err := dec.DecodeMapLen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -132,10 +137,18 @@ func (fr *FileReference) DecodeMsgpack(dec *msgpack.Decoder) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fr.History[k] = &fileVersion
|
hasHistory = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !hasExt {
|
||||||
|
fr.Ext = extMap{*linkedhashmap.New()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !hasHistory {
|
||||||
|
fr.History = fileHistoryMap{*linkedhashmap.New()}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue