From 236269941bbc850bfeb42150a1bd520874347fd6 Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Fri, 19 Feb 2021 22:43:46 +0100 Subject: [PATCH] [scraper] try to fix seeders update startup error --- scraper/scheduler/seeders.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scraper/scheduler/seeders.js b/scraper/scheduler/seeders.js index a5cdf6f..3b51dfb 100644 --- a/scraper/scheduler/seeders.js +++ b/scraper/scheduler/seeders.js @@ -10,7 +10,7 @@ const statistics = {}; function scheduleUpdateSeeders() { console.log('Starting seeders update...') - return repository.getUpdateSeedersTorrents(50) + return getTorrents() .then(torrents => updateCurrentSeeders(torrents)) .then(updatedTorrents => Promise.all( updatedTorrents.map(updated => updateLimiter.schedule(() => updateTorrentSeeders(updated))))) @@ -21,6 +21,11 @@ function scheduleUpdateSeeders() { .then(() => scheduleUpdateSeeders()); } +async function getTorrents() { + return repository.getUpdateSeedersTorrents(50) + .catch(() => delay(5000).then(() => getTorrents())) +} + function updateStatistics(updatedTorrents) { const totalTorrents = updatedTorrents.map(nested => nested.length).reduce((a, b) => a + b, 0); const date = new Date().toISOString().replace(/T.*/, '');