This commit is contained in:
Alexey Kasyanchuk 2018-08-08 23:55:47 +03:00
parent 34cdc7fb09
commit ce618f4408
17 changed files with 67 additions and 66 deletions

View File

@ -11,6 +11,7 @@
"react" "react"
], ],
"rules": { "rules": {
"indent": ["error", "tab"] "indent": ["error", "tab"],
"space-infix-ops": ["error", {"int32Hint": false}]
} }
} }

View File

@ -155,15 +155,15 @@ class App extends Component {
} }
document.addEventListener('dragover', (event) => { document.addEventListener('dragover', (event) => {
event.stopPropagation(); event.stopPropagation();
event.preventDefault();
event.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}, false);
document.addEventListener('drop', (event) => {
event.stopPropagation();
event.preventDefault(); event.preventDefault();
processTorrents(event.dataTransfer.files); // FileList object. event.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}, false); }, false);
document.addEventListener('drop', (event) => {
event.stopPropagation();
event.preventDefault();
processTorrents(event.dataTransfer.files); // FileList object.
}, false);
window.router() window.router()
appReady = true; appReady = true;

View File

@ -249,7 +249,7 @@ export default class ConfigPage extends Page {
null null
} }
{ {
this.removed > 0 && !this.toRemove && !this.toRemoveProbably this.removed > 0 && !this.toRemove && !this.toRemoveProbably
? ?
<div style={{color: 'purple'}}>{this.realRemove ? __('removing') : __('calculation')}...: {this.removed}{this.removedMax > 0 ? '/' + this.removedMax : ''}</div> <div style={{color: 'purple'}}>{this.realRemove ? __('removing') : __('calculation')}...: {this.removed}{this.removedMax > 0 ? '/' + this.removedMax : ''}</div>
: :

View File

@ -58,13 +58,13 @@ class PagesPie extends Component {
{ {
this.pie.map(({Page, params}, index) => { this.pie.map(({Page, params}, index) => {
let focus = false; let focus = false;
if (index === this.pie.length-1) { if (index === this.pie.length - 1) {
focus = true; focus = true;
} }
return ( return (
<Page <Page
focused={focus} focused={focus}
closeHandler={() => { index> 0 ? this.close() : null}} closeHandler={() => { index > 0 ? this.close() : null}}
index={index} index={index}
key={index} key={index}
ref={index} ref={index}

View File

@ -187,7 +187,7 @@ export default class Torrent extends Component {
componentDidMount() componentDidMount()
{ {
scrollBack() scrollBack()
this.downloading = (hash) => { this.downloading = (hash) => {
if(this.props.torrent.hash != hash) if(this.props.torrent.hash != hash)
@ -275,7 +275,7 @@ export default class Torrent extends Component {
return true; return true;
} }
*/ */
window.rememberYOffset = window.pageYOffset window.rememberYOffset = window.pageYOffset
window.routerFix() window.routerFix()
PagesPie.instance().open(TorrentPage, {replace: 'all', hash: torrent.hash, peer: torrent.peer}) PagesPie.instance().open(TorrentPage, {replace: 'all', hash: torrent.hash, peer: torrent.peer})
}} }}

View File

@ -1003,7 +1003,7 @@ module.exports = async ({
if(peer.info && peer.info.feed) if(peer.info && peer.info.feed)
{ {
if(peer.info.feed > feed.size() // list bigger than our if(peer.info.feed > feed.size() // list bigger than our
|| (peer.info.feed == feed.size() && peer.info.feedDate > feed.feedDate)) // or same but more new || (peer.info.feed == feed.size() && peer.info.feedDate > feed.feedDate)) // or same but more new
{ {
peer.emit('feed', null, (remoteFeed) => { peer.emit('feed', null, (remoteFeed) => {
if(!remoteFeed) if(!remoteFeed)

View File

@ -84,9 +84,9 @@ const stringHashCode = (str) => {
if (str.length === 0) if (str.length === 0)
return hash; return hash;
for (i = 0; i < str.length; i++) { for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i); chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr; hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer hash |= 0; // Convert to 32bit integer
} }
return hash; return hash;
}; };

View File

@ -3,27 +3,27 @@ var os = require("os");
//Create function to get CPU information //Create function to get CPU information
function cpuAverage() { function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info //Initialise sum of idle and time of cores and fetch CPU info
let totalIdle = 0, totalTick = 0; let totalIdle = 0, totalTick = 0;
const cpus = os.cpus(); const cpus = os.cpus();
//Loop through CPU cores //Loop through CPU cores
for(let i = 0, len = cpus.length; i < len; i++) { for(let i = 0, len = cpus.length; i < len; i++) {
//Select CPU core //Select CPU core
const cpu = cpus[i]; const cpu = cpus[i];
//Total up the time in the cores tick //Total up the time in the cores tick
for(const type in cpu.times) { for(const type in cpu.times) {
totalTick += cpu.times[type]; totalTick += cpu.times[type];
} }
//Total up the idle time of the core //Total up the idle time of the core
totalIdle += cpu.times.idle; totalIdle += cpu.times.idle;
} }
//Return the average Idle and Tick times //Return the average Idle and Tick times
return {idle: totalIdle / cpus.length, total: totalTick / cpus.length}; return {idle: totalIdle / cpus.length, total: totalTick / cpus.length};
} }
//Grab first CPU Measure //Grab first CPU Measure
@ -33,16 +33,16 @@ let percentageCPU = 0
//Set delay for second Measure //Set delay for second Measure
const cpuTimer = setInterval(function() { const cpuTimer = setInterval(function() {
//Grab second Measure //Grab second Measure
const endMeasure = cpuAverage(); const endMeasure = cpuAverage();
//Calculate the difference in idle and total time between the measures //Calculate the difference in idle and total time between the measures
const idleDifference = endMeasure.idle - startMeasure.idle; const idleDifference = endMeasure.idle - startMeasure.idle;
const totalDifference = endMeasure.total - startMeasure.total; const totalDifference = endMeasure.total - startMeasure.total;
//Calculate the average percentage CPU usage //Calculate the average percentage CPU usage
percentageCPU = 100 - ~~(100 * idleDifference / totalDifference); percentageCPU = 100 - ~~(100 * idleDifference / totalDifference);
startMeasure = endMeasure startMeasure = endMeasure
}, 300); }, 300);

View File

@ -33,7 +33,7 @@ function generateTid() {
class Spider extends Emiter { class Spider extends Emiter {
constructor(client) { constructor(client) {
super() super()
const options = arguments.length? arguments[0]: {} const options = arguments.length ? arguments[0] : {}
this.table = new Table(options.tableCaption || 1000) this.table = new Table(options.tableCaption || 1000)
this.bootstraps = options.bootstraps || bootstraps this.bootstraps = options.bootstraps || bootstraps
this.token = new Token() this.token = new Token()

View File

@ -3,7 +3,7 @@
module.exports = class { module.exports = class {
constructor() { constructor() {
this.generate() this.generate()
const it = setInterval(() => this.generate(), 60000*15) const it = setInterval(() => this.generate(), 60000 * 15)
it.unref() it.unref()
} }
@ -12,6 +12,6 @@ module.exports = class {
} }
generate() { generate() {
this.token = new Buffer([parseInt(Math.random()*200), parseInt(Math.random()*200)]) this.token = new Buffer([parseInt(Math.random() * 200), parseInt(Math.random() * 200)])
} }
} }

View File

@ -24,7 +24,7 @@ let connectTracker = function(connection) {
debug('start screape connection'); debug('start screape connection');
let buffer = new Buffer(16); let buffer = new Buffer(16);
const transactionId = Math.floor((Math.random()*100000)+1); const transactionId = Math.floor((Math.random() * 100000) + 1);
buffer.fill(0); buffer.fill(0);

View File

@ -209,7 +209,7 @@ module.exports = async (callback, mainWindow, sphinxApp) => {
if(torrentsArray.length >= 20000) if(torrentsArray.length >= 20000)
{ {
fs.writeFileSync(`${sphinxApp.directoryPath}/torrents.patch.${patch++}`, JSON.stringify(torrentsArray, null, 4), 'utf8'); fs.writeFileSync(`${sphinxApp.directoryPath}/torrents.patch.${patch++}`, JSON.stringify(torrentsArray, null, 4), 'utf8');
logT('patcher', 'write torrents dump', `${sphinxApp.directoryPath}/torrents.patch.${patch-1}`) logT('patcher', 'write torrents dump', `${sphinxApp.directoryPath}/torrents.patch.${patch - 1}`)
torrentsArray = [] torrentsArray = []
} }
}) })

View File

@ -21,9 +21,9 @@ const stringHashCode = (str) => {
if (str.length === 0) if (str.length === 0)
return hash; return hash;
for (i = 0; i < str.length; i++) { for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i); chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr; hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer hash |= 0; // Convert to 32bit integer
} }
return hash; return hash;
}; };

View File

@ -158,8 +158,8 @@ module.exports = (callback, dataDirectory, onClose) => {
} }
// check external sphinx instance for using // check external sphinx instance for using
const sphinxPid=`${sphinxConfigDirectory}/searchd.pid` const sphinxPid = `${sphinxConfigDirectory}/searchd.pid`
const isSphinxExternal=fs.existsSync(sphinxPid) && isRunning(parseInt(fs.readFileSync(sphinxPid))) const isSphinxExternal = fs.existsSync(sphinxPid) && isRunning(parseInt(fs.readFileSync(sphinxPid)))
if(isSphinxExternal) if(isSphinxExternal)
logT('sphinx', `founded running sphinx instance in ${sphinxPid}, using it`) logT('sphinx', `founded running sphinx instance in ${sphinxPid}, using it`)