mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +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
|
// called locked
|
||||||
func (state *state) edit(group, token string, expires *time.Time) (*Stateful, error) {
|
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 {
|
if state.tokens == nil {
|
||||||
return nil, os.ErrNotExist
|
return nil, os.ErrNotExist
|
||||||
}
|
}
|
||||||
|
@ -257,7 +262,7 @@ func (state *state) edit(group, token string, expires *time.Time) (*Stateful, er
|
||||||
new.Expires = expires
|
new.Expires = expires
|
||||||
state.tokens[token] = new
|
state.tokens[token] = new
|
||||||
}
|
}
|
||||||
err := state.rewrite()
|
err = state.rewrite()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.tokens[token] = old
|
state.tokens[token] = old
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue