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');
|
||||
import forBigTable from './forBigTable'
|
||||
|
||||
module.exports = ({
|
||||
sphinx,
|
||||
@ -622,23 +623,10 @@ module.exports = ({
|
||||
console.log('removed torrents by filter:', toRemove.length)
|
||||
}
|
||||
|
||||
const checker = (index = 0) => {
|
||||
sphinx.query(`SELECT * FROM torrents LIMIT ${index},50000`, (err, torrents) => {
|
||||
if(err || torrents.length == 0)
|
||||
{
|
||||
done()
|
||||
return
|
||||
}
|
||||
|
||||
torrents.forEach((torrent) => {
|
||||
forBigTable(sphinx, 'torrents', (torrent) => {
|
||||
if(!checkTorrent(torrent))
|
||||
toRemove.push(torrent)
|
||||
})
|
||||
|
||||
checker(index + torrents.length)
|
||||
});
|
||||
}
|
||||
checker()
|
||||
}, done)
|
||||
})
|
||||
|
||||
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