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

Commit

Permalink
fix: viper not looking at same dir config
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Jan 11, 2020
1 parent 8403fb0 commit e3cde61
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func InitConf(specPath string) (*Config, error) {
viper.AddConfigPath("/etc/cloud-torrent/")
viper.AddConfigPath("/etc/")
viper.AddConfigPath("$HOME/.cloud-torrent")
viper.AddConfigPath(".")

viper.SetDefault("DownloadDirectory", "./downloads")
viper.SetDefault("WatchDirectory", "./torrents")
Expand All @@ -77,6 +78,7 @@ func InitConf(specPath string) (*Config, error) {
configExists := true
if err := viper.ReadInConfig(); err != nil {
if strings.Contains(err.Error(), "Not Found") {
log.Println("[viper Config]", err)
configExists = false
if specPath == "" {
specPath = "./cloud-torrent.yaml"
Expand Down Expand Up @@ -105,7 +107,7 @@ func InitConf(specPath string) (*Config, error) {
if err := viper.WriteConfig(); err != nil {
return nil, err
}
log.Println("[config] config file written: ", cf)
log.Println("[config] config file written: ", cf, "exists:", configExists, "dirchanged", dirChanged)
}

return c, nil
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func (s *Server) Run(version string) error {

if s.Debug {
viper.Debug()
log.Printf("Effective Config: %#v", s.state.Config)
}

s.backgroundRoutines()
Expand Down
1 change: 1 addition & 0 deletions server/server_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func (s *Server) fetchSearchConfig(confurl string) error {
log.Println("fetchSearchConfig: loading search config from", confurl)
resp, err := http.Get(confurl)
if err != nil {
log.Println("[fetchSearchConfig]", err)
return err
}
defer resp.Body.Close()
Expand Down

0 comments on commit e3cde61

Please sign in to comment.