feat(config): saving configuration
This commit is contained in:
parent
5fc8ddde2b
commit
316072008a
@ -15,14 +15,14 @@ export default class AdminPage extends Page {
|
|||||||
this.loadSettings()
|
this.loadSettings()
|
||||||
}
|
}
|
||||||
loadSettings() {
|
loadSettings() {
|
||||||
window.torrentSocket.emit('admin', window.customLoader((options) => {
|
window.torrentSocket.emit('config', window.customLoader((options) => {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
console.log(this.options)
|
console.log(this.options)
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
saveSettings() {
|
saveSettings() {
|
||||||
window.torrentSocket.emit('setAdmin', this.options)
|
window.torrentSocket.emit('setConfig', this.options)
|
||||||
this.forceUpdate()
|
this.forceUpdate()
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
@ -32,12 +32,12 @@ export default class AdminPage extends Page {
|
|||||||
<div className='column center w100p pad0-75'>
|
<div className='column center w100p pad0-75'>
|
||||||
<Toggle
|
<Toggle
|
||||||
style={{marginTop: '10px'}}
|
style={{marginTop: '10px'}}
|
||||||
label="Disable DHT scanning"
|
label="Enabled network scanning"
|
||||||
toggled={this.options.dhtDisabled}
|
toggled={this.options.indexer}
|
||||||
thumbSwitchedStyle={{backgroundColor: 'red'}}
|
thumbSwitchedStyle={{backgroundColor: 'red'}}
|
||||||
trackSwitchedStyle={{backgroundColor: '#ff9d9d'}}
|
trackSwitchedStyle={{backgroundColor: '#ff9d9d'}}
|
||||||
onToggle={(e, checked) => {
|
onToggle={(e, checked) => {
|
||||||
this.options.dhtDisabled = checked
|
this.options.indexer = checked
|
||||||
this.saveSettings()
|
this.saveSettings()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -40,6 +40,12 @@ const { ipcRenderer, remote } = require('electron');
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ipcRenderer.on('url', (event, url) => {
|
||||||
|
console.log('url', url)
|
||||||
|
router(url)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Needed for onTouchTap
|
// Needed for onTouchTap
|
||||||
// http://stackoverflow.com/a/34015469/988941
|
// http://stackoverflow.com/a/34015469/988941
|
||||||
injectTapEventPlugin();
|
injectTapEventPlugin();
|
||||||
|
@ -71,7 +71,7 @@ router('/DMCA', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
router('/admi5p', () => {
|
router('/config', () => {
|
||||||
//singleton
|
//singleton
|
||||||
let pie = new PagesPie;
|
let pie = new PagesPie;
|
||||||
pie.open(AdminPage, {replace: 'all'});
|
pie.open(AdminPage, {replace: 'all'});
|
||||||
|
@ -8,6 +8,7 @@ import url from "url";
|
|||||||
import { app, Menu, ipcMain, Tray } from "electron";
|
import { app, Menu, ipcMain, Tray } from "electron";
|
||||||
import { devMenuTemplate } from "./menu/dev_menu_template";
|
import { devMenuTemplate } from "./menu/dev_menu_template";
|
||||||
import { editMenuTemplate } from "./menu/edit_menu_template";
|
import { editMenuTemplate } from "./menu/edit_menu_template";
|
||||||
|
import { settingsMenuTemplate } from "./menu/config_menu_template";
|
||||||
import createWindow from "./helpers/window";
|
import createWindow from "./helpers/window";
|
||||||
|
|
||||||
// Special module holding environment variables which you declared
|
// Special module holding environment variables which you declared
|
||||||
@ -19,7 +20,7 @@ const { spawn, exec } = require('child_process')
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
const setApplicationMenu = () => {
|
const setApplicationMenu = () => {
|
||||||
const menus = [editMenuTemplate];
|
const menus = [editMenuTemplate, settingsMenuTemplate];
|
||||||
if (env.name !== "production") {
|
if (env.name !== "production") {
|
||||||
menus.push(devMenuTemplate);
|
menus.push(devMenuTemplate);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { app } from 'electron'
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
indexer: true,
|
indexer: true,
|
||||||
|
|
||||||
@ -15,14 +17,6 @@ let config = {
|
|||||||
connectionLimit: 30
|
connectionLimit: 30
|
||||||
},
|
},
|
||||||
|
|
||||||
mysql: {
|
|
||||||
host : 'localhost',
|
|
||||||
user : 'btsearch',
|
|
||||||
password : 'pirateal100x',
|
|
||||||
database : 'btsearch',
|
|
||||||
connectionLimit: 40
|
|
||||||
},
|
|
||||||
|
|
||||||
spider: {
|
spider: {
|
||||||
walkInterval: 5,
|
walkInterval: 5,
|
||||||
cpuLimit: 0,
|
cpuLimit: 0,
|
||||||
@ -48,28 +42,34 @@ let config = {
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const debug = require('debug')('config')
|
const debug = require('debug')('config')
|
||||||
|
|
||||||
|
let configPath = 'config.json'
|
||||||
|
if(app.getPath("userData") && app.getPath("userData").length > 0)
|
||||||
|
{
|
||||||
|
configPath = app.getPath("userData") + '/config.json'
|
||||||
|
}
|
||||||
|
|
||||||
const configProxy = new Proxy(config, {
|
const configProxy = new Proxy(config, {
|
||||||
set: (target, prop, value, receiver) => {
|
set: (target, prop, value, receiver) => {
|
||||||
target[prop] = value
|
target[prop] = value
|
||||||
|
console.log('set op', configPath)
|
||||||
|
|
||||||
if(!fs.existsSync('config.json'))
|
if(!fs.existsSync(configPath))
|
||||||
fs.writeFileSync('config.json', '{}')
|
fs.writeFileSync(configPath, '{}')
|
||||||
|
|
||||||
fs.readFile('config.json', 'utf8', (err, data) => {
|
const data = fs.readFileSync(configPath)
|
||||||
let obj = JSON.parse(data)
|
let obj = JSON.parse(data)
|
||||||
obj[prop] = value;
|
obj[prop] = value;
|
||||||
fs.writeFileSync('config.json', JSON.stringify(obj, null, 4), 'utf8');
|
fs.writeFileSync(configPath, JSON.stringify(obj, null, 4), 'utf8');
|
||||||
debug('saving config.json:', prop, '=', value)
|
debug('saving config.json:', prop, '=', value)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
config.load = () => {
|
config.load = () => {
|
||||||
debug('loading configuration')
|
debug('loading configuration')
|
||||||
if(fs.existsSync('config.json'))
|
if(fs.existsSync(configPath))
|
||||||
{
|
{
|
||||||
debug('finded configuration config.json')
|
debug('finded configuration', configPath)
|
||||||
const data = fs.readFileSync('config.json', 'utf8')
|
const data = fs.readFileSync(configPath, 'utf8')
|
||||||
const obj = JSON.parse(data);
|
const obj = JSON.parse(data);
|
||||||
for(let prop in obj)
|
for(let prop in obj)
|
||||||
{
|
{
|
||||||
|
14
src/background/menu/config_menu_template.js
Normal file
14
src/background/menu/config_menu_template.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { app, BrowserWindow } from "electron";
|
||||||
|
|
||||||
|
export const settingsMenuTemplate = {
|
||||||
|
label: "Settings",
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: "Main settings",
|
||||||
|
accelerator: "CmdOrCtrl+O",
|
||||||
|
click: () => {
|
||||||
|
console.log(BrowserWindow.getFocusedWindow().webContents.send('url', '/config'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
@ -33,12 +33,6 @@ module.exports = function (send, recive)
|
|||||||
let torrentsId = 1;
|
let torrentsId = 1;
|
||||||
let filesId = 1;
|
let filesId = 1;
|
||||||
|
|
||||||
let mysqlPool = mysql.createPool({
|
|
||||||
connectionLimit: config.mysql.connectionLimit,
|
|
||||||
host : config.sphinx.host,
|
|
||||||
port : config.sphinx.port
|
|
||||||
});
|
|
||||||
|
|
||||||
let sphinx = mysql.createPool({
|
let sphinx = mysql.createPool({
|
||||||
connectionLimit: config.sphinx.connectionLimit,
|
connectionLimit: config.sphinx.connectionLimit,
|
||||||
host : config.sphinx.host,
|
host : config.sphinx.host,
|
||||||
@ -155,7 +149,7 @@ handleListenerDisconnect();
|
|||||||
app.use(express.static('build', {index: false}));
|
app.use(express.static('build', {index: false}));
|
||||||
|
|
||||||
app.get('/sitemap.xml', function(req, res) {
|
app.get('/sitemap.xml', function(req, res) {
|
||||||
mysqlPool.query('SELECT count(*) as cnt FROM `torrents` WHERE contentCategory != \'xxx\' OR contentCategory IS NULL', function (error, rows, fields) {
|
sphinx.query('SELECT count(*) as cnt FROM `torrents` WHERE contentCategory != \'xxx\' OR contentCategory IS NULL', function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -176,7 +170,7 @@ app.get('/sitemap:id.xml', function(req, res) {
|
|||||||
|
|
||||||
let page = (req.params.id - 1) * config.sitemapMaxSize
|
let page = (req.params.id - 1) * config.sitemapMaxSize
|
||||||
|
|
||||||
mysqlPool.query('SELECT hash FROM `torrents` WHERE contentCategory != \'xxx\' OR contentCategory IS NULL LIMIT ?, ?', [page, config.sitemapMaxSize], function (error, rows, fields) {
|
sphinx.query('SELECT hash FROM `torrents` WHERE contentCategory != \'xxx\' OR contentCategory IS NULL LIMIT ?, ?', [page, config.sitemapMaxSize], function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -261,7 +255,7 @@ setInterval(() => {
|
|||||||
if(typeof callback != 'function')
|
if(typeof callback != 'function')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mysqlPool.query('SELECT * FROM `torrents` ORDER BY added DESC LIMIT 0,10', function (error, rows, fields) {
|
sphinx.query('SELECT * FROM `torrents` ORDER BY added DESC LIMIT 0,10', function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
callback(undefined)
|
callback(undefined)
|
||||||
return;
|
return;
|
||||||
@ -281,7 +275,7 @@ setInterval(() => {
|
|||||||
if(typeof callback != 'function')
|
if(typeof callback != 'function')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mysqlPool.query('SELECT count(*) AS torrents, sum(size) AS sz FROM `torrents`', function (error, rows, fields) {
|
sphinx.query('SELECT count(*) AS torrents, sum(size) AS sz FROM `torrents`', function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
callback(undefined)
|
callback(undefined)
|
||||||
@ -290,7 +284,7 @@ setInterval(() => {
|
|||||||
|
|
||||||
let result = {torrents: rows[0].torrents || 0, size: rows[0].sz || 0}
|
let result = {torrents: rows[0].torrents || 0, size: rows[0].sz || 0}
|
||||||
|
|
||||||
mysqlPool.query('SELECT count(*) AS files FROM `files`', function (error, rows, fields) {
|
sphinx.query('SELECT count(*) AS files FROM `files`', function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
callback(undefined)
|
callback(undefined)
|
||||||
@ -312,7 +306,7 @@ setInterval(() => {
|
|||||||
if(typeof callback != 'function')
|
if(typeof callback != 'function')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mysqlPool.query('SELECT * FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
sphinx.query('SELECT * FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
||||||
if(!rows || rows.length == 0) {
|
if(!rows || rows.length == 0) {
|
||||||
callback(undefined)
|
callback(undefined)
|
||||||
return;
|
return;
|
||||||
@ -321,7 +315,7 @@ setInterval(() => {
|
|||||||
|
|
||||||
if(options.files)
|
if(options.files)
|
||||||
{
|
{
|
||||||
mysqlPool.query('SELECT * FROM `files` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
sphinx.query('SELECT * FROM `files` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
||||||
torrent.filesList = rows;
|
torrent.filesList = rows;
|
||||||
callback(baseRowData(torrent))
|
callback(baseRowData(torrent))
|
||||||
});
|
});
|
||||||
@ -363,27 +357,27 @@ setInterval(() => {
|
|||||||
}
|
}
|
||||||
if(navigation.type && navigation.type.length > 0)
|
if(navigation.type && navigation.type.length > 0)
|
||||||
{
|
{
|
||||||
where += ' and contentType = ' + mysqlPool.escape(navigation.type) + ' ';
|
where += ' and contentType = ' + sphinx.escape(navigation.type) + ' ';
|
||||||
}
|
}
|
||||||
if(navigation.size)
|
if(navigation.size)
|
||||||
{
|
{
|
||||||
if(navigation.size.max > 0)
|
if(navigation.size.max > 0)
|
||||||
where += ' and size < ' + mysqlPool.escape(navigation.size.max) + ' ';
|
where += ' and size < ' + sphinx.escape(navigation.size.max) + ' ';
|
||||||
if(navigation.size.min > 0)
|
if(navigation.size.min > 0)
|
||||||
where += ' and size > ' + mysqlPool.escape(navigation.size.min) + ' ';
|
where += ' and size > ' + sphinx.escape(navigation.size.min) + ' ';
|
||||||
}
|
}
|
||||||
if(navigation.files)
|
if(navigation.files)
|
||||||
{
|
{
|
||||||
if(navigation.files.max > 0)
|
if(navigation.files.max > 0)
|
||||||
where += ' and files < ' + mysqlPool.escape(navigation.files.max) + ' ';
|
where += ' and files < ' + sphinx.escape(navigation.files.max) + ' ';
|
||||||
if(navigation.files.min > 0)
|
if(navigation.files.min > 0)
|
||||||
where += ' and files > ' + mysqlPool.escape(navigation.files.min) + ' ';
|
where += ' and files > ' + sphinx.escape(navigation.files.min) + ' ';
|
||||||
}
|
}
|
||||||
console.log(navigation, where)
|
console.log(navigation, where)
|
||||||
|
|
||||||
let searchList = [];
|
let searchList = [];
|
||||||
//args.splice(orderBy && orderBy.length > 0 ? 1 : 0, 1);
|
//args.splice(orderBy && orderBy.length > 0 ? 1 : 0, 1);
|
||||||
//mysqlPool.query('SELECT * FROM `torrents` WHERE `name` like \'%' + text + '%\' ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, rows, fields) {
|
//sphinx.query('SELECT * FROM `torrents` WHERE `name` like \'%' + text + '%\' ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, rows, fields) {
|
||||||
sphinx.query('SELECT * FROM `torrents` WHERE MATCH(?) ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, rows, fields) {
|
sphinx.query('SELECT * FROM `torrents` WHERE MATCH(?) ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -429,27 +423,27 @@ setInterval(() => {
|
|||||||
}
|
}
|
||||||
if(navigation.type && navigation.type.length > 0)
|
if(navigation.type && navigation.type.length > 0)
|
||||||
{
|
{
|
||||||
where += ' and contentType = ' + mysqlPool.escape(navigation.type) + ' ';
|
where += ' and contentType = ' + sphinx.escape(navigation.type) + ' ';
|
||||||
}
|
}
|
||||||
if(navigation.size)
|
if(navigation.size)
|
||||||
{
|
{
|
||||||
if(navigation.size.max > 0)
|
if(navigation.size.max > 0)
|
||||||
where += ' and torrentSize < ' + mysqlPool.escape(navigation.size.max) + ' ';
|
where += ' and torrentSize < ' + sphinx.escape(navigation.size.max) + ' ';
|
||||||
if(navigation.size.min > 0)
|
if(navigation.size.min > 0)
|
||||||
where += ' and torrentSize > ' + mysqlPool.escape(navigation.size.min) + ' ';
|
where += ' and torrentSize > ' + sphinx.escape(navigation.size.min) + ' ';
|
||||||
}
|
}
|
||||||
if(navigation.files)
|
if(navigation.files)
|
||||||
{
|
{
|
||||||
if(navigation.files.max > 0)
|
if(navigation.files.max > 0)
|
||||||
where += ' and files < ' + mysqlPool.escape(navigation.files.max) + ' ';
|
where += ' and files < ' + sphinx.escape(navigation.files.max) + ' ';
|
||||||
if(navigation.files.min > 0)
|
if(navigation.files.min > 0)
|
||||||
where += ' and files > ' + mysqlPool.escape(navigation.files.min) + ' ';
|
where += ' and files > ' + sphinx.escape(navigation.files.min) + ' ';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let search = {};
|
let search = {};
|
||||||
//args.splice(orderBy && orderBy.length > 0 ? 1 : 0, 1);
|
//args.splice(orderBy && orderBy.length > 0 ? 1 : 0, 1);
|
||||||
//mysqlPool.query('SELECT * FROM `files` inner join torrents on(torrents.hash = files.hash) WHERE files.path like \'%' + text + '%\' ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, rows, fields) {
|
//sphinx.query('SELECT * FROM `files` inner join torrents on(torrents.hash = files.hash) WHERE files.path like \'%' + text + '%\' ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, rows, fields) {
|
||||||
sphinx.query('SELECT * FROM `files` WHERE MATCH(?) ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, files, fields) {
|
sphinx.query('SELECT * FROM `files` WHERE MATCH(?) ' + where + ' ' + order + ' LIMIT ?,?', args, function (error, files, fields) {
|
||||||
if(!files) {
|
if(!files) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -500,7 +494,7 @@ setInterval(() => {
|
|||||||
let max = 20;
|
let max = 20;
|
||||||
if(type && type.length > 0)
|
if(type && type.length > 0)
|
||||||
{
|
{
|
||||||
where += ' and contentType = ' + mysqlPool.escape(type) + ' ';
|
where += ' and contentType = ' + sphinx.escape(type) + ' ';
|
||||||
max = 15;
|
max = 15;
|
||||||
|
|
||||||
if(type == 'hours')
|
if(type == 'hours')
|
||||||
@ -523,7 +517,7 @@ setInterval(() => {
|
|||||||
callback(topCache[query]);
|
callback(topCache[query]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mysqlPool.query(query, function (error, rows) {
|
sphinx.query(query, function (error, rows) {
|
||||||
if(!rows || rows.length == 0) {
|
if(!rows || rows.length == 0) {
|
||||||
callback(undefined)
|
callback(undefined)
|
||||||
return;
|
return;
|
||||||
@ -537,29 +531,24 @@ setInterval(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
recive('admin', function(callback)
|
recive('config', (callback) =>
|
||||||
{
|
{
|
||||||
if(typeof callback != 'function')
|
if(typeof callback != 'function')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
callback({
|
callback(config)
|
||||||
dhtDisabled: !config.indexer
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
recive('setAdmin', function(options, callback)
|
recive('setConfig', (options, callback) =>
|
||||||
{
|
{
|
||||||
if(typeof options !== 'object')
|
if(typeof options !== 'object')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
config.indexer = !options.dhtDisabled;
|
for(const option in options)
|
||||||
spider.ignore = !config.indexer;
|
{
|
||||||
|
console.log('set', option, options[option])
|
||||||
if(!config.indexer)
|
if(config[option])
|
||||||
showFakeTorrents()
|
config[option] = options[option]
|
||||||
else {
|
|
||||||
hideFakeTorrents()
|
|
||||||
spider.listen(config.spiderPort)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof callback === 'function')
|
if(typeof callback === 'function')
|
||||||
@ -590,7 +579,7 @@ setInterval(() => {
|
|||||||
const ip = socketIPV4();
|
const ip = socketIPV4();
|
||||||
isGood = !!isGood;
|
isGood = !!isGood;
|
||||||
|
|
||||||
mysqlPool.query('SELECT * FROM `torrents_actions` WHERE `hash` = ? AND (`action` = \'good\' OR `action` = \'bad\') AND ipv4 = ?', [hash, ip], function (error, rows, fields) {
|
sphinx.query('SELECT * FROM `torrents_actions` WHERE `hash` = ? AND (`action` = \'good\' OR `action` = \'bad\') AND ipv4 = ?', [hash, ip], function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
@ -599,17 +588,17 @@ setInterval(() => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mysqlPool.query('SELECT good, bad FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
sphinx.query('SELECT good, bad FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
||||||
if(!rows || rows.length == 0)
|
if(!rows || rows.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let {good, bad} = rows[0];
|
let {good, bad} = rows[0];
|
||||||
const action = isGood ? 'good' : 'bad';
|
const action = isGood ? 'good' : 'bad';
|
||||||
mysqlPool.query('INSERT INTO `torrents_actions` SET ?', {hash, action, ipv4: ip}, function(err, result) {
|
sphinx.query('INSERT INTO `torrents_actions` SET ?', {hash, action, ipv4: ip}, function(err, result) {
|
||||||
if(!result) {
|
if(!result) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
mysqlPool.query('UPDATE torrents SET ' + action + ' = ' + action + ' + 1 WHERE hash = ?', hash, function(err, result) {
|
sphinx.query('UPDATE torrents SET ' + action + ' = ' + action + ' + 1 WHERE hash = ?', hash, function(err, result) {
|
||||||
if(!result) {
|
if(!result) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
@ -653,17 +642,17 @@ let popDatabaseBalance = () => {
|
|||||||
/*
|
/*
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
let stats = {};
|
let stats = {};
|
||||||
mysqlPool.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
|
sphinx.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
|
||||||
stats.torrents = rows[0].tornum;
|
stats.torrents = rows[0].tornum;
|
||||||
mysqlPool.query('SELECT COUNT(*) as filesnum, SUM(`size`) as filesizes FROM `files`', function (error, rows, fields) {
|
sphinx.query('SELECT COUNT(*) as filesnum, SUM(`size`) as filesizes FROM `files`', function (error, rows, fields) {
|
||||||
stats.files = rows[0].filesnum;
|
stats.files = rows[0].filesnum;
|
||||||
stats.size = rows[0].filesizes;
|
stats.size = rows[0].filesizes;
|
||||||
send('newStatistic', stats);
|
send('newStatistic', stats);
|
||||||
mysqlPool.query('DELETE FROM `statistic`', function (err, result) {
|
sphinx.query('DELETE FROM `statistic`', function (err, result) {
|
||||||
if(!result) {
|
if(!result) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
mysqlPool.query('INSERT INTO `statistic` SET ?', stats, function(err, result) {
|
sphinx.query('INSERT INTO `statistic` SET ?', stats, function(err, result) {
|
||||||
if(!result) {
|
if(!result) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
@ -964,7 +953,7 @@ if(config.spaceQuota)
|
|||||||
|
|
||||||
this.stop = (callback) => {
|
this.stop = (callback) => {
|
||||||
console.log('closing spider')
|
console.log('closing spider')
|
||||||
mysqlPool.end(() => spider.close(() => {
|
sphinx.end(() => spider.close(() => {
|
||||||
mysqlSingle.destroy()
|
mysqlSingle.destroy()
|
||||||
callback()
|
callback()
|
||||||
}))
|
}))
|
||||||
|
Loading…
Reference in New Issue
Block a user