eslint
This commit is contained in:
@ -243,7 +243,7 @@ module.exports = async ({
|
||||
sphinxSingle.query(`SELECT * FROM files WHERE hash IN(${inSql})`, (error, files) => {
|
||||
for(const file of files)
|
||||
hashes[file.hash].filesList = parseTorrentFiles(file);
|
||||
|
||||
|
||||
callback(Object.values(hashes))
|
||||
})
|
||||
})
|
||||
|
@ -74,24 +74,24 @@ module.exports = async (callback, mainWindow, sphinxApp) => {
|
||||
}
|
||||
#one {
|
||||
padding: 20px;
|
||||
}
|
||||
#long {
|
||||
font-size: 0.8em;
|
||||
padding: 10px;
|
||||
}
|
||||
#canBreak {
|
||||
font-size: 0.8em;
|
||||
padding: 10px;
|
||||
}
|
||||
#long {
|
||||
font-size: 0.8em;
|
||||
padding: 10px;
|
||||
}
|
||||
#canBreak {
|
||||
font-size: 0.8em;
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
const {ipcRenderer} = require('electron')
|
||||
ipcRenderer.on('reindex', (e, data) =>{
|
||||
document.getElementById('one').innerHTML = \`Updating \${data.torrent ? 'torrent': 'file'} \${data.index} of \${data.all} [\${data.field} index]\`
|
||||
if(data.longTime)
|
||||
document.getElementById('long').innerHTML = 'This patch is very long, may be some hours. So you can take some cup of tea, while we perform db patch.'
|
||||
if(data.canBreak)
|
||||
document.getElementById('canBreak').innerHTML = 'You can break this patch, and continue when you will have time to patch, it will be resumed.'
|
||||
document.getElementById('one').innerHTML = \`Updating \${data.torrent ? 'torrent': 'file'} \${data.index} of \${data.all} [\${data.field} index]\`
|
||||
if(data.longTime)
|
||||
document.getElementById('long').innerHTML = 'This patch is very long, may be some hours. So you can take some cup of tea, while we perform db patch.'
|
||||
if(data.canBreak)
|
||||
document.getElementById('canBreak').innerHTML = 'You can break this patch, and continue when you will have time to patch, it will be resumed.'
|
||||
})
|
||||
ipcRenderer.on('optimize', (e, data) =>{
|
||||
document.getElementById('one').innerHTML = \`Optimization for \${data.field}...\`
|
||||
@ -108,9 +108,9 @@ module.exports = async (callback, mainWindow, sphinxApp) => {
|
||||
c4.416,0.15,17.979,1.621,17.683-4.273c-0.292-5.897-11.491-3.241-13.854-6.487c-2.359-3.234-10.023-15.504-7.366-21.104
|
||||
c2.65-5.59,12.674-21.229,24.463-22.988c11.789-1.777,42.451,7.361,47.459,0c5.012-7.372-6.783-11.512-15.918-28.611
|
||||
C243.779,80.572,238.768,71.728,220.195,71.427z"/>
|
||||
<div id="one"></div>
|
||||
<div id="long"></div>
|
||||
<div id="canBreak"></div>
|
||||
<div id="one"></div>
|
||||
<div id="long"></div>
|
||||
<div id="canBreak"></div>
|
||||
</svg>
|
||||
</body>
|
||||
</html>
|
||||
@ -349,7 +349,7 @@ module.exports = async (callback, mainWindow, sphinxApp) => {
|
||||
}
|
||||
newId++;
|
||||
logT('patcher', 'founded newId', newId);
|
||||
|
||||
|
||||
logT('patcher', 'perform optimization');
|
||||
sphinx.query(`OPTIMIZE INDEX files`)
|
||||
await sphinxApp.waitOptimized('files')
|
||||
@ -363,7 +363,7 @@ module.exports = async (callback, mainWindow, sphinxApp) => {
|
||||
if(Field == 'size' && Type == 'string')
|
||||
isSizeAlreadyPatched = true;
|
||||
});
|
||||
|
||||
|
||||
if(!isSizeNewExists)
|
||||
await sphinx.query("alter table files add column `size_new` string");
|
||||
else
|
||||
|
@ -1,15 +1,15 @@
|
||||
const fs = require('fs')
|
||||
|
||||
module.exports = function deleteFolderRecursive(path) {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.readdirSync(path).forEach(function(file, index){
|
||||
var curPath = path + "/" + file;
|
||||
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
deleteFolderRecursive(curPath);
|
||||
} else { // delete file
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
if (fs.existsSync(path)) {
|
||||
fs.readdirSync(path).forEach(function(file, index){
|
||||
var curPath = path + "/" + file;
|
||||
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
deleteFolderRecursive(curPath);
|
||||
} else { // delete file
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
};
|
@ -105,10 +105,10 @@ module.exports = class Feed {
|
||||
const relativeTime = (maxTime - time) / maxTime
|
||||
return (
|
||||
relativeTime * relativeTime
|
||||
+ good * 1.5 * relativeTime
|
||||
+ comments * 4 * relativeTime
|
||||
- bad * 0.6 * relativeTime
|
||||
+ rating(good, bad)
|
||||
+ good * 1.5 * relativeTime
|
||||
+ comments * 4 * relativeTime
|
||||
- bad * 0.6 * relativeTime
|
||||
+ rating(good, bad)
|
||||
)
|
||||
}
|
||||
}
|
@ -460,7 +460,7 @@ class p2p {
|
||||
let fileStream
|
||||
if(!fs.existsSync(tmpPath) || !fs.lstatSync(tmpPath).isDirectory())
|
||||
fileStream = fs.createWriteStream(tmpPath)
|
||||
|
||||
|
||||
let peer = null
|
||||
let firstTransfer = false
|
||||
let deleteCallback = (remotePeer || this).emit('file', {path}, async (chunk, nil, addr) => {
|
||||
@ -514,11 +514,11 @@ class p2p {
|
||||
if(fileStream)
|
||||
fileStream.end(null, null, () => {
|
||||
fs.unlinkSync(tmpPath)
|
||||
transferFiles()
|
||||
transferFiles()
|
||||
})
|
||||
else
|
||||
transferFiles()
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -546,7 +546,7 @@ class p2p {
|
||||
firstTransfer = true
|
||||
logT('transfer', 'got peer for tranfer, start transfering file', path, 'from peer', addr.peerId)
|
||||
}
|
||||
|
||||
|
||||
const buffer = Buffer.from(data.data)
|
||||
fileStream.write(buffer)
|
||||
}, true) // dont clear callback
|
||||
|
@ -4,7 +4,7 @@ module.exports = (filesData) => {
|
||||
|
||||
let path = filesData.path.split('\n');
|
||||
let size = filesData.size.split('\n');
|
||||
|
||||
|
||||
return path.map((pathString, index) => Object.assign({}, filesData, {
|
||||
path: pathString,
|
||||
size: parseInt(size[index])
|
||||
|
@ -551,7 +551,7 @@ module.exports = function (send, recive, dataDirectory, version, env)
|
||||
path,
|
||||
pathIndex: path,
|
||||
size
|
||||
}, function(err, result) {
|
||||
}, function(err, result) {
|
||||
if(!result) {
|
||||
console.error(err);
|
||||
return
|
||||
@ -913,7 +913,7 @@ module.exports = function (send, recive, dataDirectory, version, env)
|
||||
|
||||
// save feed
|
||||
await feed.save()
|
||||
|
||||
|
||||
// close trackers if needed
|
||||
logT('close', 'closing trackers')
|
||||
await remoteTrackers.close()
|
||||
|
@ -59,14 +59,14 @@ module.exports = class Rutor
|
||||
if(!this.dataDirectory)
|
||||
return
|
||||
|
||||
if(!this.rutorMap && fs.existsSync(this.dataDirectory + '/rutor/rutor.x.json'))
|
||||
{
|
||||
let data = JSON.parse(fs.readFileSync(this.dataDirectory + '/rutor/rutor.x.json'))
|
||||
this.rutorMap = data.hashes
|
||||
logT('rutor', 'add records to', Object.keys(this.rutorMap).length)
|
||||
}
|
||||
else if(!this.rutorMap)
|
||||
this.rutorMap = {}
|
||||
if(!this.rutorMap && fs.existsSync(this.dataDirectory + '/rutor/rutor.x.json'))
|
||||
{
|
||||
let data = JSON.parse(fs.readFileSync(this.dataDirectory + '/rutor/rutor.x.json'))
|
||||
this.rutorMap = data.hashes
|
||||
logT('rutor', 'add records to', Object.keys(this.rutorMap).length)
|
||||
}
|
||||
else if(!this.rutorMap)
|
||||
this.rutorMap = {}
|
||||
|
||||
if(page > 10)
|
||||
{
|
||||
@ -84,29 +84,29 @@ module.exports = class Rutor
|
||||
return
|
||||
html = await html.textConverted()
|
||||
const $ = cheerio.load(html)
|
||||
|
||||
|
||||
const rutorMap = this.rutorMap
|
||||
$('#index tr').each(function(i, elem) {
|
||||
const row = $(this)
|
||||
const nameField = row.find('td').next()
|
||||
if(!nameField)
|
||||
const row = $(this)
|
||||
const nameField = row.find('td').next()
|
||||
if(!nameField)
|
||||
return
|
||||
let id = nameField.find('a').attr('href')
|
||||
if(!id)
|
||||
return
|
||||
id = id.match(/download\/([0-9]+)/)[1]
|
||||
id = parseInt(id)
|
||||
const hash = magnetParse(nameField.find('a').next().attr('href'))
|
||||
|
||||
rutorMap[hash] = id
|
||||
let id = nameField.find('a').attr('href')
|
||||
if(!id)
|
||||
return
|
||||
id = id.match(/download\/([0-9]+)/)[1]
|
||||
id = parseInt(id)
|
||||
const hash = magnetParse(nameField.find('a').next().attr('href'))
|
||||
|
||||
rutorMap[hash] = id
|
||||
});
|
||||
|
||||
|
||||
await mkdirp(`${this.dataDirectory}/rutor`)
|
||||
fs.writeFileSync(`${this.dataDirectory}/rutor/rutor.x.json`, JSON.stringify({
|
||||
date: Date.now(),
|
||||
hashes: this.rutorMap
|
||||
}, null, 4), 'utf8');
|
||||
|
||||
|
||||
logT('rutor', 'parse new links page', page)
|
||||
setTimeout(() => this.recheck(page + 1), 30)
|
||||
}
|
||||
@ -130,14 +130,14 @@ module.exports = class Rutor
|
||||
|
||||
let contentCategory
|
||||
$('#details tr').each(function(i, elem) {
|
||||
const row = $(this)
|
||||
const field = row.find('td.header').text()
|
||||
if(field == 'Категория')
|
||||
{
|
||||
contentCategory = row.find('td').next().text().trim()
|
||||
}
|
||||
const row = $(this)
|
||||
const field = row.find('td.header').text()
|
||||
if(field == 'Категория')
|
||||
{
|
||||
contentCategory = row.find('td').next().text().trim()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
return {
|
||||
name: topicTitle,
|
||||
@ -146,7 +146,7 @@ module.exports = class Rutor
|
||||
rutorThreadId: parseInt(id),
|
||||
contentCategory
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user