mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-22 20:42:40 +00:00
Fix home user directory detection handling (#145)
This commit is contained in:
parent
064d4d53f6
commit
dcacde0959
1 changed files with 10 additions and 5 deletions
|
@ -52,14 +52,10 @@ type config struct {
|
|||
}
|
||||
|
||||
func configWithDefaults() (*config, error) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
c := &config{}
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
|
||||
c.LogLevel = "warn"
|
||||
c.OpengistHome = filepath.Join(homeDir, ".opengist")
|
||||
c.OpengistHome = ""
|
||||
c.DBFilename = "opengist.db"
|
||||
|
||||
c.SqliteJournalMode = "WAL"
|
||||
|
@ -93,6 +89,15 @@ func InitConfig(configPath string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if c.OpengistHome == "" {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("opengist home directory is not set and current user home directory could not be determined; please specify the opengist home directory manually via the configuration")
|
||||
}
|
||||
|
||||
c.OpengistHome = filepath.Join(homeDir, ".opengist")
|
||||
}
|
||||
|
||||
if err = checks(c); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue