1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-08 17:55:59 +01:00

Resynchronise with disk when editing tokens.

We used to assume that the in-memory representation is in sync
when editing a stateful token.  That is usually the case, since
editing requires knowing the token to edit, but resynchronising
here is the right thing to do.
This commit is contained in:
Juliusz Chroboczek 2023-05-19 15:08:05 +02:00
parent 6a3b9a3b7e
commit 0de0199742

View file

@ -238,6 +238,11 @@ func Edit(group, token string, expires time.Time) (*Stateful, error) {
// called locked
func (state *state) edit(group, token string, expires *time.Time) (*Stateful, error) {
err := state.load()
if err != nil {
return nil, err
}
if state.tokens == nil {
return nil, os.ErrNotExist
}
@ -257,7 +262,7 @@ func (state *state) edit(group, token string, expires *time.Time) (*Stateful, er
new.Expires = expires
state.tokens[token] = new
}
err := state.rewrite()
err = state.rewrite()
if err != nil {
state.tokens[token] = old
return nil, err