Permalink
Browse files

fix "save" in built version, show saving status

fixes #38
  • Loading branch information...
mmckegg committed Oct 26, 2016
1 parent f7a93a8 commit ba00aaa89a63d8bcf1e379bf79fc78fb7bdb2963
Showing with 39 additions and 24 deletions.
  1. +16 −5 background-window.js
  2. +5 −18 lib/convert.js
  3. +2 −1 models/torrent-status.js
  4. +13 −0 styles/loading.mcss
  5. +3 −0 widgets/torrent-status.js
View
@@ -101,12 +101,23 @@ module.exports = function (client, config) {
}
})
function saveFile (id, torrentId, filePath) {
function saveFile (id, torrentId, exportPath) {
var torrent = torrentClient.get(torrentId)
torrent.files[0].createReadStream(0).pipe(convert.export(filePath, (err, info) => {
ipc.send('bg-response', id, err, info)
console.log(info)
}))
torrentState.get(torrent.infoHash).saving.set(true)
if (torrent.progress === 1) {
done()
} else {
torrent.once('done', done)
}
function done () {
var originalPath = Path.join(getTorrentDataPath(torrent.infoHash), torrent.files[0].path)
convert.export(originalPath, exportPath, (err, info) => {
torrentState.get(torrent.infoHash).saving.set(false)
ipc.send('bg-response', id, err, info)
console.log(info.toString())
})
}
}
})
View
@@ -20,26 +20,13 @@ module.exports.mp3 = function (input, output, cb) {
], cb)
}
module.exports.export = function (output, cb) {
var child = ffmpeg.spawn([
'-y',
'-i', 'pipe:0',
module.exports.export = function (input, output, cb) {
ffmpeg([
'-y', // overwrite existing file
'-i', input,
'-vn', // remove video if any
'-codec:a', 'libmp3lame',
'-qscale:a', 2, // High quality MP3 - since we're exporting from the opus version
output
])
var info = ''
child.stderr.on('data', (data) => {
info += data.toString()
})
child.on('error', function (err) {
cb(err, info)
}).on('close', function () {
cb(null, info)
})
return child.stdin
], cb)
}
View
@@ -14,7 +14,8 @@ function TorrentStatus (infoHash) {
uploaded: Value(0),
downloaded: Value(0),
seeding: Value(false),
loading: Value(false)
loading: Value(false),
saving: Value(false)
})
result.infoHash = infoHash
View
@@ -4,6 +4,19 @@ Loading {
align-items: center
justify-content: center
-inline {
height: 16px
width: 16px
display: inline-block
margin: -3px 3px
::before {
display: block
height: 16px
width: 16px
}
}
-large {
::before {
height: 100px
@@ -10,6 +10,9 @@ function TorrentStatusWidget (context, infoHash) {
var torrentStatus = context.background.getTorrentStatus(infoHash)
var others = when(torrentStatus.complete, torrentStatus.complete, torrentStatus.numPeers)
return h('div.status', [
when(torrentStatus.saving, [
h('span', [h('Loading -inline'), h('strong', 'Saving to disk...')])
]),
when(torrentStatus.seeding, [
when(torrentStatus.isDownloading,
h('span', [computed(torrentStatus.progress, percent)])

0 comments on commit ba00aaa

Please sign in to comment.