Be certain to clear our marshalled representation before reloading it

This commit is contained in:
Philippe M. Chiasson 2017-09-22 10:14:03 -04:00 committed by Traefiker
parent a941739f8a
commit 9db12374ea

View file

@ -199,6 +199,10 @@ func (d *Datastore) get() *Metadata {
func (d *Datastore) Load() (Object, error) {
d.localLock.Lock()
defer d.localLock.Unlock()
// clear Object first, as mapstructure's decoder doesn't have ZeroFields set to true for merging purposes
d.meta.Object = d.meta.Object[:0]
err := d.kv.LoadConfig(d.meta)
if err != nil {
return nil, err