небольшие исправления
This commit is contained in:
16
index.js
16
index.js
@ -91,6 +91,9 @@ io.on('connection', function(socket)
|
||||
|
||||
socket.on('recentTorrents', function(callback)
|
||||
{
|
||||
if(typeof callback != 'function')
|
||||
return;
|
||||
|
||||
socketMysql.query('SELECT * FROM `torrents` ORDER BY added DESC LIMIT 0,10', function (error, rows, fields) {
|
||||
let torrents = [];
|
||||
rows.forEach((row) => {
|
||||
@ -103,6 +106,9 @@ io.on('connection', function(socket)
|
||||
|
||||
socket.on('statistic', function(callback)
|
||||
{
|
||||
if(typeof callback != 'function')
|
||||
return;
|
||||
|
||||
let stats = {};
|
||||
socketMysql.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
|
||||
stats.torrents = rows[0].tornum;
|
||||
@ -118,6 +124,9 @@ io.on('connection', function(socket)
|
||||
if(hash.length != 40)
|
||||
return;
|
||||
|
||||
if(typeof callback != 'function')
|
||||
return;
|
||||
|
||||
socketMysql.query('SELECT * FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
||||
if(rows.length == 0) {
|
||||
callback(undefined);
|
||||
@ -141,9 +150,14 @@ io.on('connection', function(socket)
|
||||
|
||||
socket.on('search', function(text, callback)
|
||||
{
|
||||
if(!text || text.length <= 2)
|
||||
if(typeof callback != 'function')
|
||||
return;
|
||||
|
||||
if(!text || text.length <= 2) {
|
||||
callback(undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
let search = {};
|
||||
|
||||
console.log(text);
|
||||
|
Reference in New Issue
Block a user