diff options
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() |