Fix config persistence

This commit is contained in:
Patrick Pacher 2020-04-14 20:01:48 +02:00
parent f074aa5770
commit a842929e55
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D
2 changed files with 16 additions and 1 deletions

View file

@ -47,7 +47,7 @@ func saveConfig() error {
for key, option := range options {
option.Lock()
if option.activeValue != nil {
activeValues[key] = option.activeValue
activeValues[key] = option.activeValue.getData(option)
}
option.Unlock()
}

View file

@ -13,6 +13,21 @@ type valueCache struct {
boolVal bool
}
func (vc *valueCache) getData(opt *Option) interface{} {
switch opt.OptType {
case OptTypeBool:
return vc.boolVal
case OptTypeInt:
return vc.intVal
case OptTypeString:
return vc.stringVal
case OptTypeStringArray:
return vc.stringArrayVal
default:
return nil
}
}
func validateValue(option *Option, value interface{}) (*valueCache, error) { //nolint:gocyclo
switch v := value.(type) {
case string: