Config: Create settings.yml if it doesn't exist

This commit is contained in:
Michael Mayer 2020-12-04 12:15:59 +01:00
parent 1a31e52eaa
commit b3abe6840a

View file

@ -151,18 +151,20 @@ func (s *Settings) Save(fileName string) error {
return err
}
s.Propagate()
return nil
}
// initSettings initializes user settings from a config file.
func (c *Config) initSettings() {
c.settings = NewSettings()
p := c.SettingsFile()
fileName := c.SettingsFile()
if err := c.settings.Load(p); err != nil {
log.Debugln(err)
if err := c.settings.Load(fileName); err == nil {
log.Debugf("config: loaded settings from %s ", fileName)
} else if err := c.settings.Save(fileName); err != nil {
log.Errorf("failed creating %s: %s", fileName, err)
} else {
log.Debugf("config: created %s ", fileName)
}
i18n.SetDir(c.LocalesPath())