Merge pull request #1679 from webtorrent/then
Use promise then() instead of catch() with callbacks
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user