Fix #297: State unmarshal
It seems we have problems deserializing on top of an already initialized state. License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
parent
8e487cd880
commit
f94faa2ebb
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
|
|
||||||
"github.com/ipfs/ipfs-cluster/api"
|
"github.com/ipfs/ipfs-cluster/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -150,10 +151,14 @@ func (st *MapState) Unmarshal(bs []byte) error {
|
||||||
|
|
||||||
// snapshot is up to date
|
// snapshot is up to date
|
||||||
buf := bytes.NewBuffer(bs[1:])
|
buf := bytes.NewBuffer(bs[1:])
|
||||||
|
newState := MapState{}
|
||||||
dec := msgpack.Multicodec(msgpack.DefaultMsgpackHandle()).Decoder(buf)
|
dec := msgpack.Multicodec(msgpack.DefaultMsgpackHandle()).Decoder(buf)
|
||||||
err := dec.Decode(st)
|
err := dec.Decode(&newState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
st.PinMap = newState.PinMap
|
||||||
|
st.Version = newState.Version
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user