vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.29k stars 123 forks source link

How to update starting point (resumed downloads) #51

Closed blacktop closed 4 years ago

blacktop commented 4 years ago

How do I set the starting point for use with resumed downloads?

    p := mpb.New(
        mpb.WithWidth(60),
        mpb.WithRefreshRate(180*time.Millisecond),
    )

    bar := p.AddBar(d.size, mpb.BarStyle("[=>-|"),
        mpb.PrependDecorators(
            decor.CountersKibiByte("\t% 6.1f / % 6.1f"),
        ),
        mpb.AppendDecorators(
            decor.EwmaETA(decor.ET_STYLE_MMSS, float64(d.size)/2048),
            decor.Name(" ] "),
            decor.AverageSpeed(decor.UnitKiB, "% .2f"),
        ),
    )

    if d.canResume {
        bar.SetCurrent(d.bytesResumed )
    }
    // create proxy reader
    reader := bar.ProxyReader(resp.Body)
    defer reader.Close()
   • resuming a previous download of: iPhone12_1_13.1.1_17A854_Restore.ipsw
    1.1 GiB /    0 b [----------------------------------------------------------| -48:-3 ] 71.44 MiB/s

See the total byte sits at 0b and the estimated time is negative??

Thank you!

blacktop commented 4 years ago

My mistake I was setting the total incorrectly.

Thanks for such a great lib!

vbauerster commented 4 years ago

You can indicate resume visually with SetRefill method, example. PS: you're welcome!

blacktop commented 4 years ago

Is there a way to prevent the BPS from jumping up SUPER high when you resume?

When I resume it thinks I'm getting 3Gbs of bandwidth, but then it sloooooooowly resets the average back down to what it actually is?

vbauerster commented 4 years ago
blacktop commented 4 years ago

decor.EwmaSpeed(decor.UnitKiB, "% .2f", (float64(d.size)/2048), decor.WCSyncSpace), works great thanks!