aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-04-05 23:44:17 +0300
committerTulir Asokan <tulir@maunium.net>2019-04-05 23:44:17 +0300
commit7ad2103f8f2c9b7e3d12554634a68db973a05b36 (patch)
treee08c3eb377411bf6954ef24ff9205202f07e7296 /config
parent535fbbb4f7703845bb25484f6eb67b1389f2dd61 (diff)
Move history storage to matrix package. Fixes #90
Diffstat (limited to 'config')
-rw-r--r--config/config.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/config/config.go b/config/config.go
index 0ddb4a3..a3127c4 100644
--- a/config/config.go
+++ b/config/config.go
@@ -53,11 +53,11 @@ type Config struct {
AccessToken string `yaml:"access_token"`
HS string `yaml:"homeserver"`
- Dir string `yaml:"-"`
- CacheDir string `yaml:"cache_dir"`
- HistoryDir string `yaml:"history_dir"`
- MediaDir string `yaml:"media_dir"`
- StateDir string `yaml:"state_dir"`
+ Dir string `yaml:"-"`
+ CacheDir string `yaml:"cache_dir"`
+ HistoryPath string `yaml:"history_path"`
+ MediaDir string `yaml:"media_dir"`
+ StateDir string `yaml:"state_dir"`
Preferences UserPreferences `yaml:"-"`
AuthCache AuthCache `yaml:"-"`
@@ -70,11 +70,11 @@ type Config struct {
// NewConfig creates a config that loads data from the given directory.
func NewConfig(configDir, cacheDir string) *Config {
return &Config{
- Dir: configDir,
- CacheDir: cacheDir,
- HistoryDir: filepath.Join(cacheDir, "history"),
- StateDir: filepath.Join(cacheDir, "state"),
- MediaDir: filepath.Join(cacheDir, "media"),
+ Dir: configDir,
+ CacheDir: cacheDir,
+ HistoryPath: filepath.Join(cacheDir, "history.db"),
+ StateDir: filepath.Join(cacheDir, "state"),
+ MediaDir: filepath.Join(cacheDir, "media"),
Rooms: make(map[string]*rooms.Room),
}
@@ -82,7 +82,7 @@ func NewConfig(configDir, cacheDir string) *Config {
// Clear clears the session cache and removes all history.
func (config *Config) Clear() {
- os.RemoveAll(config.HistoryDir)
+ os.Remove(config.HistoryPath)
os.RemoveAll(config.StateDir)
os.RemoveAll(config.MediaDir)
os.RemoveAll(config.CacheDir)
@@ -91,7 +91,6 @@ func (config *Config) Clear() {
func (config *Config) CreateCacheDirs() {
os.MkdirAll(config.CacheDir, 0700)
- os.MkdirAll(config.HistoryDir, 0700)
os.MkdirAll(config.StateDir, 0700)
os.MkdirAll(config.MediaDir, 0700)
}