1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-10 02:35:58 +01:00

Remove tokens.Del.

It was unused.
This commit is contained in:
Juliusz Chroboczek 2023-07-09 11:51:18 +02:00
parent 1afb3c85b0
commit e73aaa31d7

View file

@ -215,29 +215,18 @@ func Add(token *Stateful) (*Stateful, error) {
return tokens.Add(token) return tokens.Add(token)
} }
func (state *state) Del(group, token string) error { func Edit(group, token string, expires time.Time) (*Stateful, error) {
tokens.mu.Lock() return tokens.Edit(group, token, expires)
defer tokens.mu.Unlock()
_, err := state.edit(group, token, nil)
return err
}
func Del(group, token string) error {
return tokens.Del(group, token)
} }
func (state *state) Edit(group, token string, expires time.Time) (*Stateful, error) { func (state *state) Edit(group, token string, expires time.Time) (*Stateful, error) {
tokens.mu.Lock() tokens.mu.Lock()
defer tokens.mu.Unlock() defer tokens.mu.Unlock()
return state.edit(group, token, &expires) return state.edit(group, token, expires)
}
func Edit(group, token string, expires time.Time) (*Stateful, error) {
return tokens.Edit(group, token, expires)
} }
// 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() err := state.load()
if err != nil { if err != nil {
return nil, err return nil, err
@ -254,14 +243,11 @@ func (state *state) edit(group, token string, expires *time.Time) (*Stateful, er
if old.Group != group { if old.Group != group {
return nil, os.ErrPermission return nil, os.ErrPermission
} }
var new *Stateful
if expires.Equal(time.Time{}) { new := old.Clone()
delete(state.tokens, token) new.Expires = &expires
} else {
new = old.Clone()
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