File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -364,9 +364,7 @@ func NewOptions64(max int64, options ...Option) *ProgressBar {
364
364
365
365
// ignoreLength if max bytes not known
366
366
if b .config .max == - 1 {
367
- b .config .ignoreLength = true
368
- b .config .max = int64 (b .config .width )
369
- b .config .predictTime = false
367
+ b .lengthUnknown ()
370
368
}
371
369
372
370
b .config .maxHumanized , b .config .maxHumanizedSuffix = humanizeBytes (float64 (b .config .max ),
@@ -759,6 +757,7 @@ func (p *ProgressBar) ChangeMax64(newMax int64) {
759
757
p .config .useIECUnits )
760
758
}
761
759
760
+ p .lengthKnown (newMax )
762
761
p .lock .Unlock () // so p.Add can lock
763
762
764
763
p .Add (0 ) // re-render
@@ -841,6 +840,20 @@ func (p *ProgressBar) render() error {
841
840
return nil
842
841
}
843
842
843
+ // lengthUnknown sets the progress bar to ignore the length
844
+ func (p * ProgressBar ) lengthUnknown () {
845
+ p .config .ignoreLength = true
846
+ p .config .max = int64 (p .config .width )
847
+ p .config .predictTime = false
848
+ }
849
+
850
+ // lengthKnown sets the progress bar to do not ignore the length
851
+ func (p * ProgressBar ) lengthKnown (max int64 ) {
852
+ p .config .ignoreLength = false
853
+ p .config .max = max
854
+ p .config .predictTime = true
855
+ }
856
+
844
857
// State returns the current state
845
858
func (p * ProgressBar ) State () State {
846
859
p .lock .Lock ()
You can’t perform that action at this time.
0 commit comments