Skip to content

Commit

Permalink
fix: don't update config field when writting fails
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <norman@berty.tech>
  • Loading branch information
n0izn0iz committed Nov 3, 2021
1 parent 4942bcd commit 10b44c5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ func (r *encRepo) setConfig(updated *config.Config) error {

// Do not use `*r.config = ...`. This will modify the *shared* config
// returned by `r.Config`.
if r.config, err = config.FromMap(mapconf); err != nil {
conf, err := config.FromMap(mapconf)
if err != nil {
return err
}

if err := writeConfigToDatastore(r.root, mapconf); err != nil {
if err := writeConfigToDatastore(r.root, conf); err != nil {
return err
}

r.config = conf

return nil
}

Expand Down

0 comments on commit 10b44c5

Please sign in to comment.