public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v1] index: Fix wrong last id at initialization
@ 2022-11-26 20:21 Taufiq Pohan
  0 siblings, 0 replies; only message in thread
From: Taufiq Pohan @ 2022-11-26 20:21 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Taufiq Pohan, Aldy Prastyo, VNLX Kernel Department,
	GNU/Weeb Mailing List

In main function, the return from get_last_id is added by 1.
Therefore if we dont have vn-stats.json, the id will start from 2 because
get_last_id will return 1.

Signed-off-by: Taufiq Pohan <[email protected]>
---
 index.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index 513ffad..0d935dc 100644
--- a/index.js
+++ b/index.js
@@ -71,12 +71,12 @@ function save_last_id(id)
 function get_last_id()
 {
 	if (!fs.existsSync('./vn-stats.json'))
-		return 1;
+		return 0;
 
 	const jsonVal = fs.readFileSync('./vn-stats.json');
 	let ret = JSON.parse(jsonVal);
 	if (!("last_vn_id" in ret) || isNaN(ret.last_vn_id))
-		return 1;
+		return 0;
 
 	return ret.last_vn_id
 }

base-commit: 6f43eec419f11a4850c36ec8a046a0425e38b1a2
-- 
Taufiq Pohan


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-26 20:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-26 20:21 [PATCH v1] index: Fix wrong last id at initialization Taufiq Pohan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox