From fa04323daffb8bf783ba438065a5ce47b2994bea Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 28 Apr 2020 22:00:37 +0300 Subject: Update mautrix-go and move crypto store to XDG_DATA_HOME --- config/config.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'config/config.go') diff --git a/config/config.go b/config/config.go index e9e1864..a958b1c 100644 --- a/config/config.go +++ b/config/config.go @@ -65,6 +65,7 @@ type Config struct { NotifySound bool `yaml:"notify_sound"` Dir string `yaml:"-"` + DataDir string `yaml:"data_dir"` CacheDir string `yaml:"cache_dir"` HistoryPath string `yaml:"history_path"` RoomListPath string `yaml:"room_list_path"` @@ -81,9 +82,10 @@ type Config struct { } // NewConfig creates a config that loads data from the given directory. -func NewConfig(configDir, cacheDir, downloadDir string) *Config { +func NewConfig(configDir, dataDir, cacheDir, downloadDir string) *Config { return &Config{ Dir: configDir, + DataDir: dataDir, CacheDir: cacheDir, DownloadDir: downloadDir, HistoryPath: filepath.Join(cacheDir, "history.db"), @@ -108,8 +110,14 @@ func (config *Config) Clear() { config.nosave = true } +// ClearData clears non-temporary session data. +func (config *Config) ClearData() { + _ = os.RemoveAll(config.DataDir) +} + func (config *Config) CreateCacheDirs() { _ = os.MkdirAll(config.CacheDir, 0700) + _ = os.MkdirAll(config.DataDir, 0700) _ = os.MkdirAll(config.StateDir, 0700) _ = os.MkdirAll(config.MediaDir, 0700) } @@ -122,6 +130,7 @@ func (config *Config) DeleteSession() { config.Rooms = rooms.NewRoomCache(config.RoomListPath, config.StateDir, config.RoomCacheSize, config.RoomCacheAge, config.GetUserID) config.PushRules = nil + config.ClearData() config.Clear() config.nosave = false config.CreateCacheDirs() -- cgit v1.2.3