Fix "Cannot read property 'numPiecesPresent' of undefined"

Fixes #695
This commit is contained in:
Feross Aboukhadijeh
2016-08-03 17:06:04 -07:00
parent 9670dc7a81
commit 87b9dba568

View File

@@ -255,7 +255,8 @@ module.exports = class TorrentList extends React.Component {
var isSelected = torrentSummary.selections && torrentSummary.selections[index]
var isDone = false // Are we finished torrenting it?
var progress = ''
if (torrentSummary.progress && torrentSummary.progress.files) {
if (torrentSummary.progress && torrentSummary.progress.files &&
torrentSummary.progress.files[index]) {
var fileProg = torrentSummary.progress.files[index]
isDone = fileProg.numPiecesPresent === fileProg.numPieces
progress = Math.round(100 * fileProg.numPiecesPresent / fileProg.numPieces) + '%'