fix(filter): cleaning fix on big db
This commit is contained in:
parent
0e9e40be02
commit
e581d95194
@ -1,4 +1,5 @@
|
|||||||
const ipaddr = require('ipaddr.js');
|
const ipaddr = require('ipaddr.js');
|
||||||
|
import forBigTable from './forBigTable'
|
||||||
|
|
||||||
module.exports = ({
|
module.exports = ({
|
||||||
sphinx,
|
sphinx,
|
||||||
@ -622,23 +623,10 @@ module.exports = ({
|
|||||||
console.log('removed torrents by filter:', toRemove.length)
|
console.log('removed torrents by filter:', toRemove.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
const checker = (index = 0) => {
|
forBigTable(sphinx, 'torrents', (torrent) => {
|
||||||
sphinx.query(`SELECT * FROM torrents LIMIT ${index},50000`, (err, torrents) => {
|
|
||||||
if(err || torrents.length == 0)
|
|
||||||
{
|
|
||||||
done()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
torrents.forEach((torrent) => {
|
|
||||||
if(!checkTorrent(torrent))
|
if(!checkTorrent(torrent))
|
||||||
toRemove.push(torrent)
|
toRemove.push(torrent)
|
||||||
})
|
}, done)
|
||||||
|
|
||||||
checker(index + torrents.length)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
checker()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
let socketIPV4 = () => {
|
let socketIPV4 = () => {
|
||||||
|
18
src/background/forBigTable.js
Normal file
18
src/background/forBigTable.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export default (sphinx, table, callback, doneCallback, max = 1000) => new Promise((done) => {
|
||||||
|
const checker = (index = 0) => {
|
||||||
|
sphinx.query(`SELECT * FROM ${table} WHERE id > ${index} LIMIT ${max}`, (err, torrents) => {
|
||||||
|
if(err || torrents.length == 0)
|
||||||
|
{
|
||||||
|
if(err)
|
||||||
|
console.log('big table parse error', err)
|
||||||
|
if(doneCallback)
|
||||||
|
doneCallback(true)
|
||||||
|
done(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
torrents.forEach(callback)
|
||||||
|
checker(torrents[torrents.length - 1].id)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
checker()
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user