diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-11-29 23:06:33 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-11-29 23:06:33 -0800 |
commit | 27e593e6e1e0a3e3ceb4aa493b460572fcf026c3 (patch) | |
tree | ea8fa587f294623640e76884281c72eb87245c56 /system/db/config.go | |
parent | 15b856420c99710e39bf13271860502887c9eb9a (diff) |
testing check for cache invalidation to after values are decoded
Diffstat (limited to 'system/db/config.go')
-rw-r--r-- | system/db/config.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/system/db/config.go b/system/db/config.go index edd4234..8bcf16b 100644 --- a/system/db/config.go +++ b/system/db/config.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/url" + "strings" "time" "github.com/bosssauce/ponzu/system/admin/config" @@ -25,6 +26,27 @@ func SetConfig(data url.Values) error { err := store.Update(func(tx *bolt.Tx) error { b := tx.Bucket([]byte("_config")) + // check for any multi-value fields (ex. checkbox fields) + // and correctly format for db storage. Essentially, we need + // fieldX.0: value1, fieldX.1: value2 => fieldX: []string{value1, value2} + var discardKeys []string + for k, v := range data { + if strings.Contains(k, ".") { + key := strings.Split(k, ".")[0] + + if data.Get(key) == "" { + data.Set(key, v[0]) + discardKeys = append(discardKeys, k) + } else { + data.Add(key, v[0]) + } + } + } + + for _, discardKey := range discardKeys { + data.Del(discardKey) + } + cfg := &config.Config{} dec := schema.NewDecoder() dec.SetAliasTag("json") // allows simpler struct tagging when creating a content type |