diff --git a/client/config/dfget.go b/client/config/dfget.go index 3bcfbf6ed..1afde18a2 100644 --- a/client/config/dfget.go +++ b/client/config/dfget.go @@ -90,8 +90,8 @@ type ClientOption struct { // eg: --header='Accept: *' --header='Host: abc'. Header []string `yaml:"header,omitempty" mapstructure:"header,omitempty"` - // NotBackSource indicates whether to not back source to download when p2p fails. - NotBackSource bool `yaml:"not_back_source,omitempty" mapstructure:"not_back_source,omitempty"` + // DisableBackSource indicates whether to not back source to download when p2p fails. + DisableBackSource bool `yaml:"disable_back_source,omitempty" mapstructure:"disable_back_source,omitempty"` // Insecure indicates whether skip secure verify when supernode interact with the source. Insecure bool `yaml:"insecure,omitempty" mapstructure:"insecure,omitempty"` diff --git a/client/config/dfget_darwin.go b/client/config/dfget_darwin.go index 192e232d6..656f25418 100644 --- a/client/config/dfget_darwin.go +++ b/client/config/dfget_darwin.go @@ -26,17 +26,17 @@ var dfgetConfig = ClientOption{ Output: "", Timeout: 0, BenchmarkRate: 128 * unit.KB, - RateLimit: 0, - Md5: "", - DigestMethod: "", - DigestValue: "", - Identifier: "", - CallSystem: "", - Pattern: "", - Cacerts: nil, - Filter: nil, - Header: nil, - NotBackSource: false, - Insecure: false, - ShowBar: false, + RateLimit: 0, + Md5: "", + DigestMethod: "", + DigestValue: "", + Identifier: "", + CallSystem: "", + Pattern: "", + Cacerts: nil, + Filter: nil, + Header: nil, + DisableBackSource: false, + Insecure: false, + ShowBar: false, } diff --git a/client/config/dfget_linux.go b/client/config/dfget_linux.go index 1712c8564..fdf68d2e0 100644 --- a/client/config/dfget_linux.go +++ b/client/config/dfget_linux.go @@ -22,17 +22,17 @@ var dfgetConfig = ClientOption{ URL: "", LockFile: "/var/run/dfget.lock", Output: "", - Timeout: 0, - Md5: "", - DigestMethod: "", - DigestValue: "", - Identifier: "", - CallSystem: "", - Pattern: "", - Cacerts: nil, - Filter: nil, - Header: nil, - NotBackSource: false, - Insecure: false, - ShowBar: false, + Timeout: 0, + Md5: "", + DigestMethod: "", + DigestValue: "", + Identifier: "", + CallSystem: "", + Pattern: "", + Cacerts: nil, + Filter: nil, + Header: nil, + DisableBackSource: false, + Insecure: false, + ShowBar: false, } diff --git a/client/dfget/dfget.go b/client/dfget/dfget.go index 076ea5525..91369c18a 100644 --- a/client/dfget/dfget.go +++ b/client/dfget/dfget.go @@ -120,7 +120,7 @@ func Download(cfg *config.DfgetConfig, client dfclient.DaemonClient) error { } func downloadFromSource(cfg *config.DfgetConfig, hdr map[string]string) (err error) { - if cfg.NotBackSource { + if cfg.DisableBackSource { err = fmt.Errorf("dfget download error, and back source disabled") logger.Warnf("%s", err) return err diff --git a/cmd/dfget/cmd/root.go b/cmd/dfget/cmd/root.go index 89e51e0b9..e7d032c64 100644 --- a/cmd/dfget/cmd/root.go +++ b/cmd/dfget/cmd/root.go @@ -18,6 +18,7 @@ package cmd import ( "context" + "fmt" "os" "os/exec" "strconv" @@ -85,6 +86,7 @@ var rootCmd = &cobra.Command{ func Execute() { if err := rootCmd.Execute(); err != nil { logger.Error(err) + fmt.Println(err) os.Exit(1) } } @@ -106,11 +108,7 @@ func init() { flagSet.DurationP("timeout", "e", dfgetConfig.Timeout, "timeout for file downloading task. If dfget has not finished downloading all pieces of file "+ - "before --timeout, the dfget will throw an error and exit, default see --benchmark-rate") - - flagSet.String("benchmark-rate", dfgetConfig.BenchmarkRate.String(), - "benchmark rate in format of G(B)/g/M(B)/m/K(B)/k/B which is used to calculate the default --timeout, "+ - "calculation formula: fileLength/benchmark-rate") + "before --timeout, the dfget will throw an error and exit, 0 is infinite") flagSet.String("limit", unit.Bytes(dfgetConfig.RateLimit).String(), "network bandwidth rate limit in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will be parsed as Byte, 0 is infinite") @@ -125,8 +123,9 @@ func init() { "filter some query params of url, use char '&' to separate different params, eg: -f 'key&sign' "+ "will filter 'key' and 'sign' query param. in this way, different urls can correspond to the same P2P task") - flagSet.Bool("not-back-source", dfgetConfig.NotBackSource, - "disable dfget downloading file directly from url source when peer fails to download file") + flagSet.Bool("disable-back-source", dfgetConfig.DisableBackSource, + "disable dfget downloading file directly from url source when peer fails to download file, "+ + "--limit is invalid when peer downloads the file from source") flagSet.StringP("pattern", "p", dfgetConfig.Pattern, "downloading pattern, must be p2p/cdn/source") diff --git a/cmd/scheduler/cmd/root.go b/cmd/scheduler/cmd/root.go index 8cdbb2e51..82c00ae2a 100644 --- a/cmd/scheduler/cmd/root.go +++ b/cmd/scheduler/cmd/root.go @@ -43,16 +43,16 @@ for deciding which peers transmit blocks to each other.`, DisableAutoGenTag: true, SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { - // Validate config - if err := cfg.Validate(); err != nil { - return err - } - // Initialize logger if err := logcore.InitScheduler(cfg.Console); err != nil { return errors.Wrap(err, "init scheduler logger") } + // Validate config + if err := cfg.Validate(); err != nil { + return err + } + return runScheduler() }, }