Show an error when adding a dupe torrent
This works around a WebTorrent bug where calling client.add(torrentFilePath) to add a duplicate torrent -- in other words, one whose infoHash we're already torrenting -- creates a new torrent object and later throws an error. Inconsistently, calling client.add(magnetURI) or client.add(infoHash) to add a duplicate torrent returns the existing torrent object that we're already torrenting and doesn't throw an error. This also fixes a prety nasty bug where pasting a dupe magnet link changed the torrentKey of an existing torrent, breaking the communication between the main and WebTorrent windows Fixes #364
This commit is contained in:
@@ -717,7 +717,7 @@ function torrentError (torrentKey, message) {
|
||||
|
||||
// TODO: WebTorrent should have semantic errors
|
||||
if (message.startsWith('There is already a swarm')) {
|
||||
onError(new Error('Couldn\'t add duplicate torrent'))
|
||||
onError(new Error('Can\'t add duplicate torrent'))
|
||||
} else if (!torrentSummary) {
|
||||
onError(message)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user