Skip to content

Duration becomes 0 after calling finish() #557

@suomela

Description

@suomela

If I have got a ProgressBar with ProgressStyle that uses a template like "… {elapsed}/{duration} …". As usual, I repeatedly call .inc(…) and finally .finish(). However, I am typically getting this kind of printout:

  • 0s/4s
  • 1s/4s
  • 2s/4s
  • 3s/4s
  • 4s/4s
  • 4s/0s

That is, the estimated total duration makes plenty of sense, except that after calling finish it drops to 0. I would expect that duration would reflect the real final duration when the progress bar is finished.

I guess the problem is around lines 292–297 of src/state.rs:

pub fn duration(&self) -> Duration {
    if self.len.is_none() || self.is_finished() {
        return Duration::new(0, 0);
    }
    self.started.elapsed() + self.eta()
}

It seems to be explicitly returning 0 when is_finished(). Is this intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions