Skip to content

Commit

Permalink
fix(feed): fix fileList coruption of feed replication
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Jul 22, 2018
1 parent 0e33c93 commit 27fa805
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/background/spider.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,25 +284,6 @@ app.get('*', function(req, res)
}, 90000) // try to load new peers if there is no one found
}

let undoneQueries = 0;
let pushDatabaseBalance = () => {
undoneQueries++;
if(undoneQueries >= 5000)
{
balanceDebug('start balance mysql, queries:', undoneQueries);
spider.ignore = true;
}
};
let popDatabaseBalance = () => {
undoneQueries--;
balanceDebug('balanced, queries left:', undoneQueries);
if(undoneQueries == 0)
{
balanceDebug('balance done');
spider.ignore = false;
}
};

const updateTorrentTrackers = (hash) => {
let maxSeeders = 0, maxLeechers = 0, maxCompleted = 0;
mysqlSingle.query('UPDATE torrents SET trackersChecked = ? WHERE hash = ?', [Math.floor(Date.now() / 1000), hash], (err, result) => {
Expand Down Expand Up @@ -458,6 +439,10 @@ app.get('*', function(req, res)
// clean download info if added
if(torrent.download)
delete torrent.download

// feed date clean
if(typeof torrent.feedDate !== 'undefined')
delete torrent.feedDate
}

const insertTorrentToDB = (torrent, silent) => new Promise((resolve) => {
Expand All @@ -467,6 +452,9 @@ app.get('*', function(req, res)
return
}

// duplicate object because we will do object modification
torrent = Object.assign({}, torrent)

// setup torrent record if it from db
setupTorrentRecord(torrent)

Expand Down Expand Up @@ -568,7 +556,14 @@ app.get('*', function(req, res)
if(typeof torrent !== 'object')
return

// duplicate object because we will do object modification
torrent = Object.assign({}, torrent)

// setup torrent record if it from db
setupTorrentRecord(torrent)

delete torrent.id
delete torrent.filesList

await mysqlSingle.updateValues('torrents', torrent, {hash: torrent.hash})
}
Expand Down

0 comments on commit 27fa805

Please sign in to comment.