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

Commit

Permalink
modify dfget output
Browse files Browse the repository at this point in the history
Signed-off-by: yunfeiyangbuaa <[email protected]>
  • Loading branch information
yunfeiyanggzq committed Aug 22, 2019
1 parent 8e41c83 commit 9e7e9a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cmd/dfget/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ func handleNodes() error {

func resultMsg(cfg *config.Config, end time.Time, e *errortypes.DfError) string {
if e != nil {
return fmt.Sprintf("download FAIL(%d) cost:%.3fs length:%d reason:%d error:%v",
return fmt.Sprintf("download FAIL(%d)\ncost:%.3fs length:%d\nreason:%d\nerror:%v",
e.Code, end.Sub(cfg.StartTime).Seconds(), cfg.RV.FileLength,
cfg.BackSourceReason, e)
}
return fmt.Sprintf("download SUCCESS(0) cost:%.3fs length:%d reason:%d",
end.Sub(cfg.StartTime).Seconds(), cfg.RV.FileLength, cfg.BackSourceReason)
return fmt.Sprintf("download SUCCESS !\ncost:%.3fs length:%d",
end.Sub(cfg.StartTime).Seconds(), cfg.RV.FileLength)
}

// Execute will process dfget.
Expand Down
4 changes: 2 additions & 2 deletions cmd/dfget/app/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ func (suit *dfgetSuit) TestResultMsg() {
end := cfg.StartTime.Add(100 * time.Millisecond)

msg := resultMsg(cfg, end, nil)
suit.Equal(msg, "download SUCCESS(0) cost:0.100s length:-1 reason:0")
suit.Equal(msg, "download SUCCESS !\ncost:0.100s length:-1")

msg = resultMsg(cfg, end, errortypes.New(1, "TestFail"))
suit.Equal(msg, "download FAIL(1) cost:0.100s length:-1 reason:0 error:"+
suit.Equal(msg, "download FAIL(1)\ncost:0.100s length:-1\nreason:0\nerror:"+
`{"Code":1,"Msg":"TestFail"}`)
}

Expand Down
9 changes: 5 additions & 4 deletions dfget/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ func Start(cfg *config.Config) *errortypes.DfError {

// prepare the RV-related information and create the corresponding files.
func prepare(cfg *config.Config) (err error) {
fmt.Printf("dfget version:%s", version.DFGetVersion)
fmt.Printf("workspace:%s sign:%s", cfg.WorkHome, cfg.Sign)
printer.Printf("dfget version:%s", version.DFGetVersion)
printer.Printf("workspace:%s", cfg.Sign)
printer.Printf("sign:%s", cfg.Sign)
logrus.Infof("target file path:%s", cfg.Output)

rv := &cfg.RV
Expand Down Expand Up @@ -160,7 +161,7 @@ func registerToSuperNode(cfg *config.Config, register regist.SupernodeRegister)
panic(e.Error())
}
cfg.RV.FileLength = result.FileLength
fmt.Printf("client:%s connected to node:%s", cfg.RV.LocalIP, result.Node)
printer.Printf("client:%s connected to node:%s", cfg.RV.LocalIP, result.Node)
return result, nil
}

Expand All @@ -170,7 +171,7 @@ func downloadFile(cfg *config.Config, supernodeAPI api.SupernodeAPI,
if cfg.BackSourceReason > 0 {
getter = backDown.NewBackDownloader(cfg, result)
} else {
fmt.Printf("start download by dragonfly")
printer.Printf("start download by dragonfly...")
getter = p2pDown.NewP2PDownloader(cfg, supernodeAPI, register, result)
}

Expand Down

0 comments on commit 9e7e9a9

Please sign in to comment.