Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-05-30 00:28:21 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-05-30 00:28:21 +0300
commit2c60fb03ce731fee555697b7221f0014c4f30d55 (patch)
tree1ebde7faddbde35096ec93793c0c90109baa3452
parent8dfcea0e818dc072202ffef93731e74e16128c8b (diff)
return torrent object from webtorrent.seed
-rw-r--r--index.js37
1 files changed, 21 insertions, 16 deletions
diff --git a/index.js b/index.js
index f730bda..61995e2 100644
--- a/index.js
+++ b/index.js
@@ -202,9 +202,26 @@ WebTorrent.prototype.seed = function (input, opts, onseed) {
if (!opts) opts = {}
opts.noVerify = true
+ var streams
+ var torrent = self.add(undefined, opts, function (torrent) {
+ var tasks = [function (cb) {
+ torrent.storage.load(streams, cb)
+ }]
+ if (self.dht) {
+ tasks.push(function (cb) {
+ torrent.on('dhtAnnounce', cb)
+ })
+ }
+ parallel(tasks, function (err) {
+ if (err) return self.emit('error', err)
+ if (onseed) onseed(torrent)
+ self.emit('seed', torrent)
+ })
+ })
+
createTorrent.parseInput(input, opts, function (err, files) {
if (err) return self.emit('error', err)
- var streams = files.map(function (file) { return file.getStream })
+ streams = files.map(function (file) { return file.getStream })
createTorrent(input, opts, function (err, torrentBuf) {
if (err) return self.emit('error', err)
@@ -212,23 +229,11 @@ WebTorrent.prototype.seed = function (input, opts, onseed) {
// if client was destroyed asyncronously, bail early (or `add` will throw)
if (self.destroyed) return
- self.add(torrentBuf, opts, function (torrent) {
- var tasks = [function (cb) {
- torrent.storage.load(streams, cb)
- }]
- if (self.dht) {
- tasks.push(function (cb) {
- torrent.on('dhtAnnounce', cb)
- })
- }
- parallel(tasks, function (err) {
- if (err) return self.emit('error', err)
- if (onseed) onseed(torrent)
- self.emit('seed', torrent)
- })
- })
+ torrent._onTorrentId(torrentBuf)
})
})
+
+ return torrent
}
/**