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

Commit e940416

Browse files
committed
const default config names
1 parent 12d3eeb commit e940416

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

engine/config.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const (
2525

2626
const (
2727
defaultTrackerListURL = "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt"
28+
defaultConfigFile = "cloud-torrent"
2829
)
2930

3031
type Config struct {
@@ -61,10 +62,8 @@ func InitConf(specPath *string) (*Config, error) {
6162
// user specific config path
6263
viper.SetConfigFile(*specPath)
6364
} else {
64-
viper.SetConfigName("cloud-torrent")
65-
viper.AddConfigPath("/etc/cloud-torrent/")
65+
viper.SetConfigName(defaultConfigFile)
6666
viper.AddConfigPath("/etc/")
67-
viper.AddConfigPath("$HOME/.cloud-torrent")
6867
viper.AddConfigPath(".")
6968
}
7069

@@ -93,9 +92,10 @@ func InitConf(specPath *string) (*Config, error) {
9392
// write a default config file if not exists and not provided
9493
c := &Config{}
9594
viper.Unmarshal(c)
96-
c.WriteYaml("cloud-torrent.yaml")
97-
log.Println("saved default config cloud-torrent.yaml")
98-
viper.SetConfigFile("cloud-torrent.yaml")
95+
cn := defaultConfigFile + ".yaml"
96+
c.WriteYaml(cn)
97+
viper.SetConfigFile(cn)
98+
log.Println("saved default config", cn)
9999
}
100100
}
101101

0 commit comments

Comments
 (0)