From eec241291b8548a1106ff672bfad9511cef633a0 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Fri, 30 Mar 2018 23:59:07 +0300 Subject: [PATCH] fix(p2p): fix torrents count --- src/background/spider.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/background/spider.js b/src/background/spider.js index a3d9682..9199b0c 100644 --- a/src/background/spider.js +++ b/src/background/spider.js @@ -93,8 +93,13 @@ function handleListenerDisconnect() { if(rows[0] && rows[0].mx >= 1) torrentsId = rows[0].mx + 1; + }) - p2p.info.torrents = torrentsId + mysqlSingle.query("SELECT COUNT(*) as cnt from torrents", (err, rows) => { + if(err) + return + + p2p.info.torrents = rows[0].cnt }) mysqlSingle.query("SELECT MAX(`id`) as mx from files", (err, rows) => { @@ -103,8 +108,13 @@ function handleListenerDisconnect() { if(rows[0] &&rows[0].mx >= 1) filesId = rows[0].mx + 1; + }) - p2p.info.files = filesId + mysqlSingle.query("SELECT COUNT(*) as cnt from files", (err, rows) => { + if(err) + return + + p2p.info.files = rows[0].cnt }) });