Update mautrix-go and move crypto store to XDG_DATA_HOME

This commit is contained in:
Tulir Asokan
2020-04-28 22:00:37 +03:00
parent 92d4279b21
commit fa04323daf
6 changed files with 79 additions and 36 deletions

View File

@ -135,7 +135,7 @@ func (c *Container) InitClient() error {
c.client.Logger = mxLogger{}
c.client.DeviceID = c.config.DeviceID
cryptoStore, err := crypto.NewGobStore(filepath.Join(c.config.CacheDir, "crypto.gob"))
cryptoStore, err := crypto.NewGobStore(filepath.Join(c.config.DataDir, "crypto.gob"))
if err != nil {
return err
}
@ -281,8 +281,8 @@ func (c *Container) Login(user, password string) error {
// Logout revokes the access token, stops the syncer and calls the OnLogout() method of the UI.
func (c *Container) Logout() {
c.client.Logout()
c.config.DeleteSession()
c.Stop()
c.config.DeleteSession()
c.client = nil
c.crypto = nil
c.ui.OnLogout()
@ -300,6 +300,11 @@ func (c *Container) Stop() {
debug.Print("Error closing history manager:", err)
}
c.history = nil
debug.Print("Flushing crypto store")
err = c.crypto.Store.Flush()
if err != nil {
debug.Print("Error flushing crypto store:", err)
}
}
}
@ -558,7 +563,6 @@ func (c *Container) HandleEncrypted(source EventSource, mxEvent *event.Event) {
debug.Print("Failed to decrypt event:", err)
return
}
debug.Print("!!!!!", evt)
c.HandleMessage(source, evt)
}