This commit is contained in:
Alexey Kasyanchuk 2018-11-11 23:59:38 +03:00
parent 6afe85798a
commit aa75d75448
13 changed files with 129 additions and 129 deletions

View File

@ -15,31 +15,31 @@ class PagesPie extends Component {
delete params.replace;
}
if (Array.isArray(pages)) {
for (let i in pages) {
this.pie.push({
Page: pages[i],
params: params
});
}
} else {
this.pie.push({
Page: pages,
params: params
});
}
if(this._mounted)
this.forceUpdate()
}
componentWillMount()
{
this._mounted = true
}
for (let i in pages) {
this.pie.push({
Page: pages[i],
params: params
});
}
} else {
this.pie.push({
Page: pages,
params: params
});
}
if(this._mounted)
this.forceUpdate()
}
componentWillMount()
{
this._mounted = true
}
componentWillUnmount()
{
this._mounted = false
}
componentWillUnmount()
{
this._mounted = false
}
close(count) {
if (count && typeof count === 'number') {
@ -59,7 +59,7 @@ class PagesPie extends Component {
}
// ОТРИСОВКА
render() {
if (this.pie.length > 0) {
if (this.pie.length > 0) {
return (
<div
className={'pie full-size ' + (this.props.className || '')}

View File

@ -104,19 +104,19 @@ const treeToTorrentFiles = (tree, torrent, toggles) => {
leftIcon={!tree[file].__fileBT ? <FileFolder /> : contentIcon(fileTypeDetect({path: file}))}
rightToggle={
newToggles.length > 0
?
<Toggle
toggled={newToggles.every( ({selected}) => selected )}
onToggle={(e, checked) => {
e.preventDefault()
e.stopPropagation()
let toggleValues = {}
newToggles.forEach(({downloadIndex}) => toggleValues[downloadIndex] = checked)
window.torrentSocket.emit('downloadSelectFiles', torrent, toggleValues)
}}
/>
:
null
?
<Toggle
toggled={newToggles.every( ({selected}) => selected )}
onToggle={(e, checked) => {
e.preventDefault()
e.stopPropagation()
let toggleValues = {}
newToggles.forEach(({downloadIndex}) => toggleValues[downloadIndex] = checked)
window.torrentSocket.emit('downloadSelectFiles', torrent, toggleValues)
}}
/>
:
null
}
/>);

View File

@ -302,13 +302,13 @@ export default class Torrent extends Component {
node.onclick = () => { return false }
}}>
<div className='column' style={{height: 'auto', whiteSpace: 'normal', paddingTop: '0.30em'}}>
{
torrent.info && torrent.info.name
&&
<div className='row w100p inline fs0-85' style={{color: 'grey', padding: '4px 0px 5px'}}>
{torrent.info.name}
</div>
}
{
torrent.info && torrent.info.name
&&
<div className='row w100p inline fs0-85' style={{color: 'grey', padding: '4px 0px 5px'}}>
{torrent.info.name}
</div>
}
<div className='row w100p inline'>
<div style={{color: torrent.contentCategory != 'xxx' ? (torrent.peer ? '#5252d1' : 'black') : (torrent.peer ? '#9083e2' : 'grey')}}>
{
@ -320,17 +320,17 @@ export default class Torrent extends Component {
torrent.path && torrent.path.length > 0
?
torrent.path.map((path, index) => {
const boldRe = /\<b\>(.+?)\<\/b\>/g;
let boldText;
let newPath = [];
let idx = 0;
while ((boldText = boldRe.exec(path)) !== null) {
newPath.push(<span>{path.substring(idx, boldText.index)}</span>);
newPath.push(<b>{boldText[1]}</b>);
idx = boldRe.lastIndex;
}
newPath.push(<span>{path.substring(idx, path.length)}</span>);
return <div key={index} className='break-word fs0-75' style={{paddingTop: '0.3em', marginLeft: '0.6em'}}>{newPath}</div>
const boldRe = /\<b\>(.+?)\<\/b\>/g;
let boldText;
let newPath = [];
let idx = 0;
while ((boldText = boldRe.exec(path)) !== null) {
newPath.push(<span>{path.substring(idx, boldText.index)}</span>);
newPath.push(<b>{boldText[1]}</b>);
idx = boldRe.lastIndex;
}
newPath.push(<span>{path.substring(idx, path.length)}</span>);
return <div key={index} className='break-word fs0-75' style={{paddingTop: '0.3em', marginLeft: '0.6em'}}>{newPath}</div>
})
:
null

View File

@ -30,7 +30,7 @@ export default (props) => {
{
info.trackers.includes('rutor')
&&
<a href={`http://www.rutor.is/torrent/${info.rutorThreadId}`}><img src={RutorIcon} style={{height: 32}} /></a>
<a href={`http://www.rutor.is/torrent/${info.rutorThreadId}`}><img src={RutorIcon} style={{height: 32}} /></a>
}
</div>
)

View File

@ -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))
})
})

View File

@ -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

View File

@ -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);
}
};

View File

@ -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)
)
}
}

View File

@ -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

View File

@ -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])

View File

@ -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()

View File

@ -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
}
}
}

View File

@ -36,7 +36,7 @@ describe("sphinx", () => {
throw new Error(err)
if(result.length !== 1)
throw new Error('not one result')
if(result[0].size != 50)
throw new Error('not 50 in field')