couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject couch-mrview commit: updated refs/heads/master to b743459
Date Wed, 08 Jul 2015 20:56:26 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/master 1c10f21cf -> b743459e4


Protect against div by zero

COUCHDB-2742


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/b743459e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/b743459e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/b743459e

Branch: refs/heads/master
Commit: b743459e4c3fd7a84d9605ffce652777162b8eb9
Parents: 1c10f21
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Jul 8 21:33:17 2015 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 8 21:35:38 2015 +0100

----------------------------------------------------------------------
 src/couch_mrview_compactor.erl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/b743459e/src/couch_mrview_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_compactor.erl b/src/couch_mrview_compactor.erl
index 6d9382f..9dba094 100644
--- a/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview_compactor.erl
@@ -235,12 +235,13 @@ update_task(Acc, ChangesInc) ->
 update_task(VID, #acc{changes=Changes, total_changes=Total}=Acc, ChangesInc) ->
     Phase = if is_integer(VID) -> view; true -> ids end,
     Changes2 = Changes + ChangesInc,
+    Progress = if Total == 0 -> 0; true -> (Changes2 * 100) div Total end,
     couch_task_status:update([
         {phase, Phase},
         {view, VID},
         {changes_done, Changes2},
         {total_changes, Total},
-        {progress, (Changes2 * 100) div Total}
+        {progress, Progress}
     ]),
     Acc#acc{changes = Changes2}.
 


Mime
View raw message