Skip to content

Commit f14cdcb

Browse files
committed
fix(search): double search on DHT
1 parent 91cfb39 commit f14cdcb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/background/api.js

+17
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,24 @@ module.exports = async ({
339339
if(rows.length === 0 && isSHA1 && !isP2P) // trying to get via dht
340340
{
341341
logT('search', 'get torrent via infohash with dht')
342+
// double check torrent magnet
343+
let secondTry = false;
344+
const doubleCheckTimeout = setTimeout(() => {
345+
secondTry = true;
346+
logT('search', 'second try search by dht')
347+
torrentClient.getMetadata(text, (torrent) => {
348+
logT('search', 'dht search found something')
349+
searchList.push(baseRowData(torrent));
350+
callback(searchList);
351+
})
352+
}, 8000)
342353
torrentClient.getMetadata(text, (torrent) => {
354+
clearTimeout(doubleCheckTimeout);
355+
if(secondTry) {
356+
logT('search', 'ignore search dht resopond because of second try')
357+
return
358+
}
359+
logT('search', 'dht search found something')
343360
searchList.push(baseRowData(torrent));
344361
callback(searchList);
345362
})

tests/download.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe("download", function() {
4444
let progress = parseInt(await (await app.client.$('.torrentRow .progressDownloading')).getText());
4545
console.log('download progress', progress, '%');
4646
// cancel in progress button must be exists
47-
if (progress < 90) {
47+
if (progress < 50) {
4848
console.log('testing buttons')
4949
assert(await (await app.client.$('.torrentRow .deleteDownloadBeforeFinish')).isExisting());
5050
assert(await (await app.client.$('.torrentRow .pauseTorrent')).isExisting());

0 commit comments

Comments
 (0)