Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
const default config names
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Sep 17, 2021
1 parent 12d3eeb commit e940416
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (

const (
defaultTrackerListURL = "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt"
defaultConfigFile = "cloud-torrent"
)

type Config struct {
Expand Down Expand Up @@ -61,10 +62,8 @@ func InitConf(specPath *string) (*Config, error) {
// user specific config path
viper.SetConfigFile(*specPath)
} else {
viper.SetConfigName("cloud-torrent")
viper.AddConfigPath("/etc/cloud-torrent/")
viper.SetConfigName(defaultConfigFile)
viper.AddConfigPath("/etc/")
viper.AddConfigPath("$HOME/.cloud-torrent")
viper.AddConfigPath(".")
}

Expand Down Expand Up @@ -93,9 +92,10 @@ func InitConf(specPath *string) (*Config, error) {
// write a default config file if not exists and not provided
c := &Config{}
viper.Unmarshal(c)
c.WriteYaml("cloud-torrent.yaml")
log.Println("saved default config cloud-torrent.yaml")
viper.SetConfigFile("cloud-torrent.yaml")
cn := defaultConfigFile + ".yaml"
c.WriteYaml(cn)
viper.SetConfigFile(cn)
log.Println("saved default config", cn)
}
}

Expand Down

0 comments on commit e940416

Please sign in to comment.