fix "default templates are re-added upon restart"

Mentioned in #161
This commit is contained in:
2024-07-08 10:19:44 +02:00
parent 3edebbdb6c
commit c0c2fcb009
4 changed files with 37 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package config
import (
"os"
"path/filepath"
"sync"
"gopkg.in/yaml.v3"
@@ -20,6 +21,7 @@ type Config struct {
Password string `yaml:"password"`
QueueSize int `yaml:"queue_size"`
SessionFilePath string `yaml:"session_file_path"`
path string
}
var (
@@ -43,9 +45,17 @@ func (c *Config) LoadFile(filename string) error {
return err
}
c.path = filename
if err := yaml.NewDecoder(fd).Decode(c); err != nil {
return err
}
return nil
}
// Path of the directory containing the config file
func (c *Config) Dir() string { return filepath.Dir(c.path) }
// Absolute path of the config file
func (c *Config) Path() string { return c.path }