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

event when torrent is complete #383

Closed
webchaz opened this issue Jul 20, 2015 · 4 comments
Closed

event when torrent is complete #383

webchaz opened this issue Jul 20, 2015 · 4 comments
Labels

Comments

@webchaz
Copy link

@webchaz webchaz commented Jul 20, 2015

I found that there's a torrent.on('done') event, but this seems to trigger before the torrent is fully complete. The progress is at 100, but there's still some more bytes to download for another second or so. Is there a way to find out when it's completely finished?

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jul 20, 2015

What makes you think that there are still more bytes to download after the 'done' event is emitted? How are you trying to read the files?

@webchaz

This comment has been minimized.

Copy link
Author

@webchaz webchaz commented Jul 20, 2015

I have the torrent.swarm.on('download') event logging and also a torrent.on('done') event, the done event logs and then there's still some more logs from the download event.

I also added client.destroy() inside the done event and this resulted in a file size that was a bit shy from the expected size.

@webchaz

This comment has been minimized.

Copy link
Author

@webchaz webchaz commented Jul 21, 2015

@feross Here's an example of it: https://gist.github.com/webchaz/ffee62ba9db52c9355ed

You'll see here that it will fire the done event, before the download event is finished. If you uncomment the lines 34-36, you'll see that the file size is cut short.

@stale stale bot added the stale label May 3, 2018
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 4, 2018

@webchaz This issue is likely caused by us requesting the same pieces from multiple peers simultaneously. When the final piece arrives from a peer, we emit 'done' but a few more peers continue to send pieces before we can close the connections.

Just a guess. Not ideal, I agree. If you send a PR to fix this, I'll happily review it.

@feross feross closed this May 4, 2018
@webtorrent webtorrent deleted a comment from stale bot May 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.