diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2014-09-17 07:37:15 +0400 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2014-09-17 07:37:15 +0400 |
commit | eb0321e9f900787af6fe77f07f0ccc52bfdc5e9e (patch) | |
tree | 0c3339532937c9702c84ec14cbdc0fba7370a81c /bin | |
parent | 1d93189d7cae98e8233f445ad58fe51543851f68 (diff) |
command line: don't crash on invalid torrent filename
fixes #94
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cmd.js | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -158,19 +158,22 @@ function remove (cb) { var torrent = client.add(torrentId) -function updateMetadata () { - var numPeers = torrent.swarm.numPeers - clivas.clear() - clivas.line('{green:fetching torrent metadata from} {bold:'+numPeers+'} {green:peers}') -} -if (!argv.quiet && !argv.list) { - torrent.swarm.on('wire', updateMetadata) - torrent.on('metadata', function () { - torrent.swarm.removeListener('wire', updateMetadata) - }) - updateMetadata() -} +torrent.on('infoHash', function () { + function updateMetadata () { + var numPeers = torrent.swarm.numPeers + clivas.clear() + clivas.line('{green:fetching torrent metadata from} {bold:'+numPeers+'} {green:peers}') + } + + if (!argv.quiet && !argv.list) { + torrent.swarm.on('wire', updateMetadata) + torrent.on('metadata', function () { + torrent.swarm.removeListener('wire', updateMetadata) + }) + updateMetadata() + } +}) client.on('torrent', function (torrent) { if (client.listening) onTorrent(torrent) |