From cb114367ac65986546b218a6e142bc5b1b876438 Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Tue, 21 Mar 2017 13:05:29 +0100 Subject: [PATCH] fix progress indicator in case of 0 incopmlete dats #311 --- models/repos.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/repos.js b/models/repos.js index be7381ed..067654df 100644 --- a/models/repos.js +++ b/models/repos.js @@ -292,9 +292,11 @@ function createModel () { var incomplete = dats.filter(function (dat) { return dat.network && dat.progress < 1 }) - var progress = incomplete.reduce(function (acc, dat) { - return acc + dat.progress - }, 0) / incomplete.length + var progress = incomplete.length + ? incomplete.reduce(function (acc, dat) { + return acc + dat.progress + }, 0) / incomplete.length + : 1 if (progress === 1) progress = -1 // deactivate ipc.send('progress', progress)