Skip to content

Commit

Permalink
Do not set the default values in the struct we're unmarshaling into
Browse files Browse the repository at this point in the history
closes pterodactyl/panel#1786

If you set the defaults, you'll override a bunch of values for the server with the original values. For example this code caused servers in a running state to be changed to a non-running state, thus leading to stats not sending.

Just merge in any new values, leave everything else as empty.
  • Loading branch information
DaneEveritt committed Dec 25, 2019
1 parent ea867d1 commit d9ceb96
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions server/update.go
Expand Up @@ -3,7 +3,6 @@ package server
import (
"encoding/json"
"github.com/buger/jsonparser"
"github.com/creasty/defaults"
"github.com/imdario/mergo"
"github.com/pkg/errors"
"go.uber.org/zap"
Expand All @@ -30,11 +29,6 @@ func (s *Server) UpdateDataStructure(data []byte, background bool) error {
return errors.New("attempting to merge a data stack with an invalid UUID")
}

// Set the default values in the interface that we unmarshaled into.
if err := defaults.Set(src); err != nil {
return errors.WithStack(err)
}

// Merge the new data object that we have received with the existing server data object
// and then save it to the disk so it is persistent.
if err := mergo.Merge(s, src, mergo.WithOverride); err != nil {
Expand Down

0 comments on commit d9ceb96

Please sign in to comment.