Merge pull request #1679 from webtorrent/then

Use promise then() instead of catch() with callbacks
This commit is contained in:
Feross Aboukhadijeh
2019-09-10 11:05:12 -07:00
committed by GitHub
2 changed files with 13 additions and 7 deletions

View File

@@ -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

View File

@@ -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) {