mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +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:
parent
6a3b9a3b7e
commit
0de0199742
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue