Merge pull request #1077 from AudriusButkevicius/round

Avoid rounding errors (fixes #1068)
This commit is contained in:
Jakob Borg 2014-12-04 05:52:29 +01:00
commit 591c5dabf4

View File

@ -181,14 +181,13 @@ angular.module('syncthing.core')
progress[folder] = {}; progress[folder] = {};
for (var file in stats[folder]) { for (var file in stats[folder]) {
var s = stats[folder][file]; var s = stats[folder][file];
var reused = Math.floor(100 * s.Reused / s.Total); var reused = 100 * s.Reused / s.Total;
var copiedFromOrigin = Math.floor(100 * s.CopiedFromOrigin / s.Total); var copiedFromOrigin = 100 * s.CopiedFromOrigin / s.Total;
var copiedFromElsewhere = Math.floor(100 * s.CopiedFromElsewhere / s.Total); var copiedFromElsewhere = 100 * s.CopiedFromElsewhere / s.Total;
var pulled = Math.floor(100 * s.Pulled / s.Total); var pulled = 100 * s.Pulled / s.Total;
var pulling = Math.floor(100 * s.Pulling / s.Total); var pulling = 100 * s.Pulling / s.Total;
// We can do the following, because if s.Pulling > 0, than reused + copied + pulled < 100 because off rounding them down. // We try to round up pulling to atleast a percent so that it would be atleast a bit visible.
// We do this to show which files are currently being pulled if (pulling < 1 && pulled + copiedFromElsewhere + copiedFromOrigin + reused <= 99) {
if (s.Pulling && pulling == 0) {
pulling = 1; pulling = 1;
} }
progress[folder][file] = { progress[folder][file] = {