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

Destroy/Start a torrent with the same info hash #1060

Closed
swrap opened this issue Feb 25, 2017 · 2 comments
Closed

Destroy/Start a torrent with the same info hash #1060

swrap opened this issue Feb 25, 2017 · 2 comments

Comments

@swrap
Copy link

@swrap swrap commented Feb 25, 2017

webtorrent: 0.98.8
OS: Ubuntu 14.04.5 LTS
Node: 7.5.0
npm: 4.2.0

Stopped a torrent download with the following code:

const t = client.get(infoHash);
if(t) {
    t.destroy();
}

Then tried to start a torrent with the same info hash again pointed at the same path:

var torrent = client.add(infoHash, { path : pathway.join(TORRENT_DIR, infoHash) });
torrent.on('ready', () => {
    console.log("Torrent-Object: ready [" + infoHash + "]");
}
torrent.on("noPeers", function(announceType) {
    console.log("Torrent-Object:  No Peers Found for torrent [" + torrent.infoHash + "] announceType [" + announceType + "]");
}

....with the rest of the .on methods

I expected the torrent to start downloading again.

Instead this these events were fired and the torrent was not downloaded:

Torrent-Object: ready [6a02592d2bbc069628cd5ed8a54f88ee06ac0ba5]
Torrent-Object:  No Peers Found for torrent [6a02592d2bbc069628cd5ed8a54f88ee06ac0ba5] announceType [dht]

I have spent some time attempting to figure this out, by looking at both the webtorrent-desktop and this repository for answers. I tried a couple different approaches through some of the issues that have been posted, but to no avail. Thanks again for this great library, but could you please lend some help!

EDIT:
The torrent does start downloading again after about 16 minutes. Here are some more logs:

Update-Torrent: download event [6a02592d2bbc069628cd5ed8a54f88ee06ac0ba5] [16384] [Sat Feb 25 2017 10:43:55 GMT-0500 (EST)]

...destroyed the torrent
...started a new torrent with the same info hash and path again

Update-Torrent: download event [6a02592d2bbc069628cd5ed8a54f88ee06ac0ba5] [16384] [Sat Feb 25 2017 10:59:28 GMT-0500 (EST)]

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Mar 8, 2017

How long did you wait after destroying before you added it back again? You should probably be waiting until the destroy() function's callback is called, or else things might be in a weird state.

Try:

torrent.destroy(function () {
  client.add(/* ... */)
})

Also, if you can share a minimal code example that can reliably reproduce the issue that would help immensely.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Apr 21, 2018

This issue appears stale since it has been open for a while with no activity. I'm going to close it for now. If this is still issue, please feel free to leave a comment or open a new issue.

@feross feross closed this Apr 21, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 20, 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.