diff options
author | Tulir Asokan <tulir@maunium.net> | 2020-04-28 22:00:37 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2020-04-28 22:00:37 +0300 |
commit | fa04323daffb8bf783ba438065a5ce47b2994bea (patch) | |
tree | e1976c16a0bd40e3f3db895cc1d848ea3be97b1a /config | |
parent | 92d4279b216987ebdfbea4577965ffb192e7726a (diff) |
Update mautrix-go and move crypto store to XDG_DATA_HOME
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 11 |
1 files changed, 10 insertions, 1 deletions
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() |