Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for unknown-size bars #6

Open
Holzhaus opened this issue Feb 15, 2022 · 1 comment
Open

Add support for unknown-size bars #6

Holzhaus opened this issue Feb 15, 2022 · 1 comment

Comments

@Holzhaus
Copy link

I'm using this library for showing download progress. Occasionally, servers don't specify a Content-Length header, so the total download size is unknown.

This lead to my code calling progress.bar(0) which works, but leads to a panic later on when progress.set_and_draw(&bar, value) is called:

thread 'main' panicked at 'attempt to divide by zero', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/linya-0.2.1/src/lib.rs:200:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

My current workaround is this:

let bar_size = if download_size > 0 { download_size } else { 1 };
let progress_bar = progress.bar(bar_size, &url);

This works, but it's not apparent to the user that his progress bar is not finished yet. It would be nice if there was some kind of spinner style bar when the total size is 0 (that is updated manually each time set_and_draw is used), and some explicit way to mark the bar as finished.

(Thanks for this great library btw, finally one that actually supports multibars with a single thread).

@fosskers
Copy link
Owner

fosskers commented Feb 23, 2022

Spinner support has been on my mind for some time. It seems like a definite lack of an important feature here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants