summaryrefslogtreecommitdiffstats
path: root/pkg/config
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-08-28 13:24:52 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-09-04 17:50:49 +0200
commitf7db17f7d05280d83d57f7266dbc4e9d3ba2c48a (patch)
tree2031aa8ed6e827e2a77e83b69f9169fa8fd50159 /pkg/config
parent1106981827f5730ae9e71ff38bde27751fc66213 (diff)
Load defaults for AppState before reading from yaml
So far this hasn't been necessary because all defaults were zero values. We're about to add the first non-zero value though, and it's important that it is initialized correctly for users who have a state.yml that doesn't have it yet.
Diffstat (limited to 'pkg/config')
-rw-r--r--pkg/config/app_config.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go
index a9872ea1e..ea26dd872 100644
--- a/pkg/config/app_config.go
+++ b/pkg/config/app_config.go
@@ -283,11 +283,13 @@ func (c *AppConfig) SaveAppState() error {
// loadAppState loads recorded AppState from file
func loadAppState() (*AppState, error) {
+ appState := getDefaultAppState()
+
filepath, err := configFilePath("state.yml")
if err != nil {
if os.IsPermission(err) {
// apparently when people have read-only permissions they prefer us to fail silently
- return getDefaultAppState(), nil
+ return appState, nil
}
return nil, err
}
@@ -298,10 +300,9 @@ func loadAppState() (*AppState, error) {
}
if len(appStateBytes) == 0 {
- return getDefaultAppState(), nil
+ return appState, nil
}
- appState := &AppState{}
err = yaml.Unmarshal(appStateBytes, appState)
if err != nil {
return nil, err