-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
Recommended way to know when a torrent is completely downloaded #168
Comments
Hi, some good ideas. I'll try to give a full response in a day or two. |
+1 |
You could subscribe to Torrent.PieceStateChanges, every time you get an event, check for the state you want.
Depending on how you intend to use the data, the more typical way to do this with this library is make use of the Reader. Something like this, with error checking not included:
|
Has this worked for you guys? |
I think that a Completed method that returns a channel would be ideally the best solution, as pointed out by the author of this PR, but the workaround you provided works as well. |
After reading #243 , I think a method for this is a good idea. In particular, a context.Context can be given to allow "giving up", and the method can return an error if for some reason the entire torrent, or the file waited on, is not correctly prioritized, to prevent indefinite stalling due to incorrect priorities. Testing this will also be much easier as a result. |
There's nothing in the works to address this in the manner you request. I think it might detract from the flexibility of the package to encourage it. Feel free to discuss more. |
Hi,
the first example of the documentation waits for all downloads to be completed:
I would like to be notified when a specific torrent is downloaded.
Should I do an busy-wait loop with
t.BytesCompleted() == t.Info().TotalLength()
? (like https://github.com/anacrolix/torrent/blob/master/cmd/torrent/main.go#L50) with sometime.Sleep
in betweenWhen
BytesCompleted
is the right value, does it also mean that the content was successfully written to the disk ? (or might there be some delay?)Ideally, I would like a
Completed
method (which would return a channel) like theClosed
.Thank you!
The text was updated successfully, but these errors were encountered: