Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
bugfix: delete the default value for supernodes from dfdaemon
Browse files Browse the repository at this point in the history
Signed-off-by: Starnop <[email protected]>
  • Loading branch information
starnop committed Oct 25, 2019
1 parent 6bc6db4 commit 0ec8e8d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/dfdaemon/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func init() {
rf.String("localrepo", filepath.Join(os.Getenv("HOME"), ".small-dragonfly/dfdaemon/data/"), "temp output dir of dfdaemon")
rf.String("dfpath", defaultDfgetPath, "dfget path")
rf.Var(netutils.NetLimit(), "ratelimit", "net speed limit")
rf.StringSlice("node", []string{"127.0.0.1:8002"}, "specify the addresses(host:port) of supernodes that will be passed to dfget.")
rf.StringSlice("node", nil, "specify the addresses(host:port) of supernodes that will be passed to dfget.")

exitOnError(bindRootFlags(viper.GetViper()), "bind root command flags")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/dfdaemon/app/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (ts *rootTestSuite) TestNodeFlag() {
r.Equal([]string{"127.0.0.1:6666"}, cfg.SuperNodes)
}

// flag not set, config file doesn't exist, should use default
// flag not set, config file doesn't exist, should be nil
{
v := viper.New()
v.SetFs(fs)
Expand All @@ -86,7 +86,7 @@ func (ts *rootTestSuite) TestNodeFlag() {
r.NotNil(readConfigFile(v, rootCmd))
cfg, err := getConfigFromViper(rootCmd, v)
r.Nil(err)
r.Equal([]string{"127.0.0.1:8002"}, cfg.SuperNodes)
r.EqualValues([]string(nil), cfg.SuperNodes)
}

// when --node flag is set, should always use the flag
Expand Down
4 changes: 3 additions & 1 deletion dfdaemon/downloader/dfget/dfget.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func (dfGetter *DFGetter) getCommand(
}
add("-s", dfGetter.config.RateLimit)
add("--totallimit", dfGetter.config.RateLimit)
add("--node", strings.Join(dfGetter.config.SuperNodes, ","))
if len(dfGetter.config.SuperNodes) > 0 {
add("--node", strings.Join(dfGetter.config.SuperNodes, ","))
}

for key, value := range header {
// discard HTTP host header for backing to source successfully
Expand Down

0 comments on commit 0ec8e8d

Please sign in to comment.