From cea0175e70651efb7f435635229dd8495644d8ef Mon Sep 17 00:00:00 2001 From: Daan Wynen Date: Sat, 13 Jul 2024 13:23:08 +0200 Subject: [PATCH] fix: avoid overflow error when computing overall progress --- db.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db.js b/db.js index 09a05cc6..54cecfc3 100644 --- a/db.js +++ b/db.js @@ -27,7 +27,8 @@ module.exports = function db (dir, keys, opts) { var c = db.views[name].since.value current += (Number.isInteger(c) ? c : -1) } - prog.current = ~~(current / n) + // we use BigInt to avoid overflow errors + prog.current = Number(~~(BigInt(current) / BigInt(n))) // if the progress bar is complete, move the starting point // up to the current position! if (prog.start <= 0) {