-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
Torrent.BytesMissing can be out of sync with storage #828
Comments
Yeah you can get BytesMissing==0 while data is still being written storage. The value tracks the state internal to the client, when it's 0, it's not expecting to need to download any more to complete a Torrent, but it could if piece hashing fails or there's a storage issue. It would be possible to change it to track the storage. It would be helpful to know what you're coordinating with BytesMissing. |
@anacrolix Thanks for your reply.
pcs := torrent.SubscribePieceStateChanges()
for torrent.BytesMissing() > 0 {
select {
case <-pcs.Values:
case <- time.After(time.Second*60):
return
}
// data has download completely, return to client
_, err := io.copy(http.ResponseWriter, torrent.file) Or what is the right practice to judge whether data is downloaded and complete? |
It's always safe to read directly from the Torrent or File Readers. You probably want to be using Torrent.File.NewReader and just stream directly out of that without doing any manual prioritizations.
See https://github.com/anacrolix/confluence/blob/master/confluence/misc.go#L82, and follow https://github.com/anacrolix/confluence/blob/master/confluence/mux.go#L19 through to its conclusion for a full example. |
@anacrolix thanks, I will have a try. |
@anacrolix Thanks, this is work. By the way, Is there a way for a peer to disable outgoing connect? we use torrent to distribute image and have a role named origin. Origin is responsible for downloading data from source and make torrent, and other peer fetch torrent from origin and start p2p download. I think origin has no need to outgoing connect, as it has all data and just wait for connect. maybe set 'HalfOpenConnsPerTorrent' to zero work? |
@luodw That's a fantastic question. A quick look suggests setting |
Hi, we have a trouble when use torrent to distribute data with torrent version 1.15.1. We use Torrent.BytesMissing() to judge whether data is completely downloaded and return data to client.
But some times Torrent.BytesMissing() == 0 and the data returned is incomplete, the data has some content with zero, so client download failed. It is happened occasionally. I guess although Torrent.BytesMissing() == 0, but some chunks may be not written to file.
Has anyone encountered this issue before? or has any ideas?
The text was updated successfully, but these errors were encountered: