Remove empty anonymous sessions after a certain time period

This commit is contained in:
Ken-Håvard Lieng 2016-01-19 22:02:12 +01:00
parent 3bcea0ec98
commit e856b66f97
6 changed files with 77 additions and 14 deletions

View file

@ -2,6 +2,7 @@ package storage
import (
"bytes"
"os"
"strconv"
"github.com/khlieng/dispatch/Godeps/_workspace/src/github.com/boltdb/bolt"
@ -169,9 +170,12 @@ func (u *User) RemoveChannel(server, channel string) {
})
}
func (u *User) Close() {
u.messageLog.Close()
u.messageIndex.Close()
func (u *User) Remove() {
db.Batch(func(tx *bolt.Tx) error {
return tx.Bucket(bucketUsers).Delete(u.id)
})
u.closeMessageLog()
os.RemoveAll(Path.User(u.Username))
}
func (u *User) serverID(address string) []byte {