Skip to content

Commit

Permalink
Merge pull request #1679 from webtorrent/then
Browse files Browse the repository at this point in the history
Use promise then() instead of catch() with callbacks
  • Loading branch information
feross authored Sep 10, 2019
2 parents 992ab0b + dd13de5 commit 4a10a2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/renderer/lib/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ function setupStateSaved (cb) {
})

Promise.all(tasks)
.then(() => cb(null, saved))
.catch(err => cb(err))
.then(
() => cb(null, saved),
err => cb(err)
)

function createTorrentObject (t) {
// TODO: Doing several fs.readFileSync calls during first startup is not ideal
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/webtorrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,15 @@ function getAudioMetadata (infoHash, index) {
: mm.parseStream(file.createReadStream(), file.name, options)

onMetaData
.then(() => {
console.log(`metadata for file='${file.name}' completed.`)
}).catch(function (err) {
return console.log('error getting audio metadata for ' + infoHash + ':' + index, err)
})
.then(
() => console.log(`metadata for file='${file.name}' completed.`),
err => {
console.log(
`error getting audio metadata for ${infoHash}:${index}`,
err
)
}
)
}

function selectFiles (torrentOrInfoHash, selections) {
Expand Down

0 comments on commit 4a10a2d

Please sign in to comment.