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) Promise.all(tasks)
.then(() => cb(null, saved)) .then(
.catch(err => cb(err)) () => cb(null, saved),
err => cb(err)
)
function createTorrentObject (t) { function createTorrentObject (t) {
// TODO: Doing several fs.readFileSync calls during first startup is not ideal // 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) : mm.parseStream(file.createReadStream(), file.name, options)
onMetaData onMetaData
.then(() => { .then(
console.log(`metadata for file='${file.name}' completed.`) () => console.log(`metadata for file='${file.name}' completed.`),
}).catch(function (err) { err => {
return console.log('error getting audio metadata for ' + infoHash + ':' + index, err) console.log(
}) `error getting audio metadata for ${infoHash}:${index}`,
err
)
}
)
} }
function selectFiles (torrentOrInfoHash, selections) { function selectFiles (torrentOrInfoHash, selections) {