Skip to content

Commit

Permalink
fix(search): double search on DHT
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Feb 18, 2021
1 parent 91cfb39 commit f14cdcb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/background/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,24 @@ module.exports = async ({
if(rows.length === 0 && isSHA1 && !isP2P) // trying to get via dht
{
logT('search', 'get torrent via infohash with dht')
// double check torrent magnet
let secondTry = false;
const doubleCheckTimeout = setTimeout(() => {
secondTry = true;
logT('search', 'second try search by dht')
torrentClient.getMetadata(text, (torrent) => {
logT('search', 'dht search found something')
searchList.push(baseRowData(torrent));
callback(searchList);
})
}, 8000)
torrentClient.getMetadata(text, (torrent) => {
clearTimeout(doubleCheckTimeout);
if(secondTry) {
logT('search', 'ignore search dht resopond because of second try')
return
}
logT('search', 'dht search found something')
searchList.push(baseRowData(torrent));
callback(searchList);
})
Expand Down
2 changes: 1 addition & 1 deletion tests/download.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("download", function() {
let progress = parseInt(await (await app.client.$('.torrentRow .progressDownloading')).getText());
console.log('download progress', progress, '%');
// cancel in progress button must be exists
if (progress < 90) {
if (progress < 50) {
console.log('testing buttons')
assert(await (await app.client.$('.torrentRow .deleteDownloadBeforeFinish')).isExisting());
assert(await (await app.client.$('.torrentRow .pauseTorrent')).isExisting());
Expand Down

0 comments on commit f14cdcb

Please sign in to comment.