Fix playback + download of default torrents

There was a terrible bug introduced in 0809e20a6e -- clicking play on any of the default torrents in a fresh install of the app would fail and result in a 'path missing' error.

This fixes the bug, and also adds a migration step to clean up resulting broken config files
This commit is contained in:
DC
2016-08-22 21:07:59 -07:00
parent 6a46609cca
commit 6d4b8c3c26
2 changed files with 38 additions and 5 deletions

View File

@@ -84,21 +84,30 @@ module.exports = class TorrentListController {
var s = TorrentSummary.getByKey(this.state, torrentKey)
if (!s) throw new Error('Missing key: ' + torrentKey)
// Use Downloads folder by default
if (!s.path) s.path = this.state.saved.prefs.downloadPath
// New torrent: give it a path
if (!s.path) {
// Use Downloads folder by default
s.path = this.state.saved.prefs.downloadPath
return start()
}
// Existing torrent: check that the path is still there
fs.stat(TorrentSummary.getFileOrFolder(s), function (err) {
if (err) {
s.error = 'path-missing'
return
}
start()
})
function start () {
ipcRenderer.send('wt-start-torrenting',
s.torrentKey,
TorrentSummary.getTorrentID(s),
s.path,
s.fileModtimes,
s.selections)
})
}
}
// TODO: use torrentKey, not infoHash