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

onTorrentStarted called twice #117

Closed
fawzibr opened this issue Jun 24, 2019 · 3 comments
Closed

onTorrentStarted called twice #117

fawzibr opened this issue Jun 24, 2019 · 3 comments
Labels
Milestone

Comments

@fawzibr
Copy link

fawzibr commented Jun 24, 2019

From what I understand and the tests I've run (version 1.8), when a torrent is started, the onTorrentStarted event is called twice, once when the client starts (no DataDescriptor available) and again when the metadata is parsed/received (the DataDescriptor is available).

Why not instead of calling the same event twice which is confusing (it's already started, why do it again) add a new event onMetadataReceived(TorrentMetadataEvent) with the DataDescriptor as part of the event?

Also is there a way to get the BtClient/BtRuntime from the TorrentId and viceversa?

@atomashpolskiy
Copy link
Owner

You're right, fixed.

Also is there a way to get the BtClient/BtRuntime from the TorrentId and viceversa?

I'm afraid that it's not possible currently, so the user has to track this mapping manually.

@atomashpolskiy atomashpolskiy added this to the 1.9 milestone Jun 30, 2019
@fawzibr
Copy link
Author

fawzibr commented Jul 4, 2019

One question, tried to check the code but since it is all futures/multi-threaded stuff I have little idea of what it is doing internally. Before on first onTorrentStarted there was no data descriptor, on second onTorrentStarted the DataDescriptor existed.

Now I guess there is only one call to onTorrentStarted and the DataDescriptor exists right?

There is another feature request (maybe bug?)

Lets say I have a torrent with 100 pieces (chunks). I download half (50 pieces) and stop it. After I resume the first 50 pieces are skipped and the last 50 downloaded. I imagine those 50 first pieces are checked to see if there are valid but it seems the onPieceVerified event is not called for those 50 first pieces. Since they are being verified when the torrent resumed I think the event should be called as well.

@atomashpolskiy
Copy link
Owner

Now I guess there is only one call to onTorrentStarted and the DataDescriptor exists right?

Yes, there is one call to onTorrentStarted, but the DataDescriptor does not exist yet. It will be present when onMetadataAvailable is called.

Lets say I have a torrent with 100 pieces (chunks). I download half (50 pieces) and stop it. After I resume the first 50 pieces are skipped and the last 50 downloaded. I imagine those 50 first pieces are checked to see if there are valid but it seems the onPieceVerified event is not called for those 50 first pieces. Since they are being verified when the torrent resumed I think the event should be called as well.

Yes, existing data is verified, when resuming partially downloaded torrent. But, indeed, it does not notify listeners. Thank you for letting me know, I'll create a new issue.

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

No branches or pull requests

2 participants