mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
internal/build: improve download progress
This commit is contained in:
parent
85459e1439
commit
d6d900afee
1 changed files with 3 additions and 6 deletions
|
|
@ -79,7 +79,7 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
fmt.Printf("%s is stale\n", dstPath)
|
fmt.Printf("%s is stale\n", dstPath)
|
||||||
fmt.Printf("downloading from %s\n", url)
|
fmt.Printf("Downloading from %s\n", url)
|
||||||
|
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -130,10 +130,7 @@ func (w *downloadWriter) Write(buf []byte) (int, error) {
|
||||||
w.written += int64(n)
|
w.written += int64(n)
|
||||||
pct := w.written * 10 / w.size * 10
|
pct := w.written * 10 / w.size * 10
|
||||||
if pct != w.lastpct {
|
if pct != w.lastpct {
|
||||||
if w.lastpct != 0 {
|
fmt.Print("\rProgress: ", pct, "%")
|
||||||
fmt.Print("...")
|
|
||||||
}
|
|
||||||
fmt.Print(pct, "%")
|
|
||||||
w.lastpct = pct
|
w.lastpct = pct
|
||||||
}
|
}
|
||||||
return n, err
|
return n, err
|
||||||
|
|
@ -141,7 +138,7 @@ func (w *downloadWriter) Write(buf []byte) (int, error) {
|
||||||
|
|
||||||
func (w *downloadWriter) Close() error {
|
func (w *downloadWriter) Close() error {
|
||||||
if w.lastpct > 0 {
|
if w.lastpct > 0 {
|
||||||
fmt.Println() // Finish the progress line.
|
fmt.Println("\rDownload complete.") // Finish the progress line.
|
||||||
}
|
}
|
||||||
flushErr := w.dstBuf.Flush()
|
flushErr := w.dstBuf.Flush()
|
||||||
closeErr := w.file.Close()
|
closeErr := w.file.Close()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue