Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uperror handling for duplicate torrents #351
Closed
Conversation
| self.emit('error', err, torrent) | ||
| self.remove(torrent) | ||
| var alreadyExistsMessage = 'There is already a swarm with info hash' | ||
| if (ontorrent && err.message && err.message.substr(0, alreadyExistsMessage.length) === alreadyExistsMessage) { |
This comment has been minimized.
This comment has been minimized.
| self.remove(torrent) | ||
| var alreadyExistsMessage = 'There is already a swarm with info hash' | ||
| if (ontorrent && err.message && err.message.substr(0, alreadyExistsMessage.length) === alreadyExistsMessage) { | ||
| self.torrents.splice(self.torrents.indexOf(torrent), 1) |
This comment has been minimized.
This comment has been minimized.
madd512
Jun 7, 2015
Author
can't call self.remove because it does other stuff like destroying the torrent
| torrent = self.torrents.filter(function (_torrent) { | ||
| return torrent.infoHash === _torrent.infoHash | ||
| })[0] | ||
| process.nextTick(clientOnTorrent.bind(null, torrent)) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Just noticing - running |
This comment has been minimized.
This comment has been minimized.
|
I think we can solve this more easily by just checking if I used your test cases (thanks!) and solved this using |
This comment has been minimized.
This comment has been minimized.
|
Great. I wanted to use client.get for this but couldn't quite figure out how. I'm glad you could. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
madd512 commentedJun 7, 2015
I'm mostly happy with this solution.
I'd be even happier if I could detect the error message by a safer means than message string comparison, but I didn't want to over-complicate.
Tests pass.