Skip to content

Commit

Permalink
Merge pull request #1419 from Borewit/fix/issue-1417
Browse files Browse the repository at this point in the history
Fix startup problems (fix for #1417)
  • Loading branch information
codealchemist authored Jun 10, 2018
2 parents 91fc7ca + 5cdb3d0 commit a1cfe87
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/renderer/lib/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ function setupStateSaved (cb) {
const cpFile = require('cp-file')
const fs = require('fs')
const parseTorrent = require('parse-torrent')
const parallel = require('run-parallel')

const saved = {
prefs: {
Expand All @@ -133,26 +132,25 @@ function setupStateSaved (cb) {

const tasks = []

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

parallel(tasks, function (err) {
if (err) return cb(err)
cb(null, saved)
})
Promise.all(tasks)
.then(() => cb(null, saved))
.catch(err => cb(err))

function createTorrentObject (t) {
// TODO: Doing several fs.readFileSync calls during first startup is not ideal
Expand Down

0 comments on commit a1cfe87

Please sign in to comment.