fix(p2p): fix files in db count on new architecture

This commit is contained in:
Alexey Kasyanchuk 2018-12-04 23:04:42 +03:00
parent 491b99fd08
commit 9ed0ad9683

View File

@ -117,7 +117,11 @@ module.exports = function (send, recive, dataDirectory, version, env)
filesId = (await sphinxSingle.query("SELECT MAX(`id`) as mx from files"))[0] filesId = (await sphinxSingle.query("SELECT MAX(`id`) as mx from files"))[0]
filesId = ((filesId && filesId.mx) || 0) + 1 filesId = ((filesId && filesId.mx) || 0) + 1
p2p.info.torrents = (await sphinxSingle.query("SELECT COUNT(*) as cnt from torrents"))[0].cnt p2p.info.torrents = (await sphinxSingle.query("SELECT COUNT(*) as cnt from torrents"))[0].cnt
p2p.info.files = (await sphinxSingle.query("SELECT COUNT(*) as cnt from files"))[0].cnt p2p.info.files = await sphinxSingle.query("SELECT SUM(files) as cnt from torrents")
if(p2p.info.files && p2p.info.files.length > 0)
p2p.info.files = p2p.info.files[0].cnt
else
p2p.info.files = 0
const sphinxSingleAlternative = await single().waitConnection() const sphinxSingleAlternative = await single().waitConnection()