only load users if they don't exist already

another guess for #77.
This commit is contained in:
Harvey Tindall 2021-04-06 13:53:07 +01:00
parent 76b822213e
commit afedc78113
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
1 changed files with 11 additions and 1 deletions

View File

@ -482,7 +482,17 @@ func (st *Storage) storeInvites() error {
func (st *Storage) loadUsers() error {
st.usersLock.Lock()
defer st.usersLock.Unlock()
return loadJSON(st.users_path, &st.users)
temp := map[string]time.Time{}
err := loadJSON(st.users_path, &temp)
if err != nil {
return err
}
for id, t1 := range temp {
if _, ok := st.users[id]; !ok {
st.users[id] = t1
}
}
return nil
}
func (st *Storage) storeUsers() error {