Avoid promise resolve results are ending up as error objects in callback handler.

Reference: issue: webtorrent/webtorrent-desktop#1417
This commit is contained in:
Borewit
2018-06-07 21:48:45 +02:00
parent c1329938f5
commit b010dc28d2

View File

@@ -133,19 +133,19 @@ function setupStateSaved (cb) {
const tasks = [] const tasks = []
config.DEFAULT_TORRENTS.map(function (t, i) { config.DEFAULT_TORRENTS.map((t, i) => {
const infoHash = saved.torrents[i].infoHash const infoHash = saved.torrents[i].infoHash
tasks.push(function (cb) { tasks.push(cb => {
cpFile( cpFile(
path.join(config.STATIC_PATH, t.posterFileName), path.join(config.STATIC_PATH, t.posterFileName),
path.join(config.POSTER_PATH, infoHash + path.extname(t.posterFileName)) path.join(config.POSTER_PATH, infoHash + path.extname(t.posterFileName))
).then(cb).catch(cb) ).then(() => cb()).catch(cb)
}) })
tasks.push(function (cb) { tasks.push(cb => {
cpFile( cpFile(
path.join(config.STATIC_PATH, t.torrentFileName), path.join(config.STATIC_PATH, t.torrentFileName),
path.join(config.TORRENT_PATH, infoHash + '.torrent') path.join(config.TORRENT_PATH, infoHash + '.torrent')
).then(cb).catch(cb) ).then(() => cb()).catch(cb)
}) })
}) })