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

Couple of changes to cmd.js #600

Closed
wants to merge 12 commits into from
Prev

Reverted f158146

Signed-off-by: Vincent Frentzel <vincent@frentzel.eu>
  • Loading branch information
Vincent Frentzel
Vincent Frentzel committed Feb 7, 2016
commit 785f7403c86a14eda747c3f6b19a6f486bf954bf
@@ -263,7 +263,7 @@ function runCreate (input) {
})
}

var client, href, playerName, server
var client, href, playerName, server, serving

function runDownload (torrentId) {
if (!argv.out && !argv.stdout && !playerName) {
@@ -306,7 +306,22 @@ function runDownload (torrentId) {
)
})

torrent.on('done', torrentDone)
torrent.on('done', function () {
if (!argv.quiet) {
var numActiveWires = torrent.swarm.wires.reduce(function (num, wire) {
return num + (wire.downloaded > 0)
}, 0)
clivas.line('')
clivas.line(
'torrent downloaded {green:successfully} from {bold:%s/%s} {green:peers} ' +
'in {bold:%ss}!',
numActiveWires,
torrent.numPeers,
getRuntime()
)
}
torrentDone()
})

// Start http server
server = torrent.createServer()
@@ -327,6 +342,10 @@ function runDownload (torrentId) {
}
})

server.once('connection', function () {
serving = true
})

function onReady () {
// if no index specified, use largest file
var index = (typeof argv.index === 'number')
@@ -592,7 +611,7 @@ function drawTorrent (torrent) {

function torrentDone () {
if (argv['on-done']) cp.exec(argv['on-done']).unref()
if (argv['exit']) gracefulExit()
if (argv['exit'] && !playerName && !serving && argv.out) gracefulExit()
}

function fatalError (err) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.