-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Show a simple status line while downloading #1984
Conversation
Since it may take 20 minutes or even an hour or a few hours to finish downloading, it may be good to see a status, to see that at least the downloading has started and what speed it is going on with. This shows a simple status line as to what speed it is moving along and what percentage is done.
docs/get-started.md
Outdated
}) | ||
|
||
torrent.on('download', function (bytes) { | ||
if (!isDone) process.stdout.write(`\rtotal: ${torrent.length} progress: ${(client.progress * 100).toFixed(2)}% ${Math.round(client.downloadSpeed / 1024).toFixed(1)} KB/s downloading...`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any need in adding this condition.
Every time the event download
is called, is because you have downloaded something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested and it does seem that without isDone
you will continue to get a few download
calls showing the progress after done
is called. Is this what you are experiencing as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, at first I didn't have the isDone
, and after the "Done" message is printed, then there is one additional progress message that got printed that messed up the screen. If the event occurs such that the progress always happens first, and then the done
occurs, then there is no need for the isDone
flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could defer done to next event loop to solve this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I agree @DiegoRBaquero (I have created an issue for this #2143)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this LGTM however I usually like to see total downloaded/total size, download speed, upload speed, peers, and progress as well. Also, it would be cool to see an ETA from the timeRemaining
property. I tried adding minutes & seconds but it doesn't look that good IMO.
I use a separate function usually to convert to human readable ETA however it isn't a one-liner.
Maybe someone has a better solution for the milliseconds to ETA format?
Also, not sure why the downloadSpeed
is coming from the client
and not the torrent
object?
use torrent's `downloadSpeed` and `progress`
8c15c98
to
d78055b
Compare
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? |
What is the purpose of this pull request? (put an "X" next to item)
[X] Documentation update
[ ] Bug fix
[ ] New feature
[ ] Other, please explain:
What changes did you make? (Give an overview)
Show a simple status line while downloading
Which issue (if any) does this pull request address?
Since it may take 20 minutes or even an hour or a few hours to finish downloading, it may be good to see a status, to see that at least the downloading has started and what speed it is going on with.
This shows a simple status line as to what speed it is moving along and what percentage is done.
Is there anything you'd like reviewers to focus on?