vbauerster / mpb

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

SetTotal not working with complex bar #131

Closed nabbar closed 10 months ago

nabbar commented 10 months ago

Hello,

First of all thank you for your library, it's great :)

I have a problem with the latest version v8 and the "complex bar". This issue was not found in V5. (I just upgraded to V8, but this problem seems to be present in v6, v7 too).

I made an example here: Go Playground

Here's the problem:

Make a loop for each bar:

The bar with a total set at creation will work normally but the bar created with 0 as total will have 0 when executed, even after a SetTotal.

When I analyze, not all complex bars have started, this value has a false value: bState.triggerComplete. But once the first bar is finished, this value will have real value for all the others.

I think the problem comes from this test which is triggered once a bar is finished and remains valid for all the others. image

https://github.com/vbauerster/mpb/blob/master/bar.go#L211

It's possible that I missed something, unless it's a bug or expected behavior (but in this case, I didn't see it in the migration details)

vbauerster commented 10 months ago

Hi! In short calling EnableTriggerComplete disables setting total. For more please refer to: https://github.com/vbauerster/mpb/blob/fab44347b86bef9303c52067ebfb1b8831acacd1/bar_test.go#L70 https://github.com/vbauerster/mpb/blob/fab44347b86bef9303c52067ebfb1b8831acacd1/bar_test.go#L101