cmd/torrent/main.go | 7 ++++++- diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index a346cdfbc8ffe91bdaa8580a0e1f7bba0e248479..02e5899725c7615f5a1fdcdb9c55642f958fabdf 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -34,6 +34,7 @@ if t.Info() == nil { fmt.Printf("getting info for %q\n", t.Name()) <-t.GotInfo() } + var lastLine string for { var completedPieces, partialPieces int psrs := t.PieceStateRuns() @@ -45,7 +46,7 @@ if r.Partial { partialPieces += r.Length } } - fmt.Printf( + line := fmt.Sprintf( "downloading %q: %s/%s, %d/%d pieces completed (%d partial)\n", t.Name(), humanize.Bytes(uint64(t.BytesCompleted())), @@ -54,6 +55,10 @@ completedPieces, t.NumPieces(), partialPieces, ) + if line != lastLine { + lastLine = line + os.Stdout.WriteString(line) + } if pieceStates { fmt.Println(psrs) }