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

Added pause/resume, refactored code, improved command line interface, etc #514

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

got all tests to pass but one

  • Loading branch information
whitef0x0 committed Nov 30, 2015
commit 2415418a7a786bf6eb70b55faf364bcac8870dbc
@@ -169,8 +169,8 @@ WebTorrent.prototype.get = function (torrentId) {
WebTorrent.prototype.add =
WebTorrent.prototype.download = function (torrentId, opts, ontorrent) {
var self = this
if (self.destroyed) return self.emit('error', new Error('client is destroyed'))
if (typeof opts === 'function') return self.add(torrentId, opts, null)
if (self.destroyed) return self.emit('error', new Error('download client is destroyed'))
if (typeof opts === 'function') return self.add(torrentId, null, opts)
debug('add')
if (!opts) opts = {}
else opts = extend({}, opts)
@@ -246,7 +246,7 @@ WebTorrent.prototype.resume = function (currentTorrent) {
*/
WebTorrent.prototype.seed = function (input, opts, onseed) {
var self = this
if (self.destroyed) return self.emit('error', new Error('client is destroyed'))
if (self.destroyed) return self.emit('error', new Error('seed client is destroyed'))
if (typeof opts === 'function') return self.seed(input, null, opts)
debug('seed')
if (!opts) opts = {}
@@ -224,18 +224,18 @@ test('after client.destroy(), throw on client.add() or client.seed()', function

var client = new WebTorrent({ dht: false, tracker: false })

client.on('error', function (err) { t.fail(err) })
client.on('error', function (err) {
if ('Error: download client is destroyed') t.pass('error emitted on client.add()')
else if ('Error: seed client is destroyed') t.pass('error emitted on client.seed()')
else t.fail(err)
})
client.on('warning', function (err) { t.fail(err) })

client.destroy(function () {
t.pass('client destroyed')
})
t.throws(function () {
client.add('magnet:?xt=urn:btih:' + leavesTorrent.infoHash)
})
t.throws(function () {
client.seed(new Buffer('sup'))
})
client.add('magnet:?xt=urn:btih:' + leavesTorrent.infoHash)
client.seed(new Buffer('sup'))
})

test('after client.destroy(), no "torrent" or "ready" events emitted', function (t) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.