From: ebelcrom Date: Wed, 27 Jan 2021 14:53:49 +0000 (+0100) Subject: clearing queue fixed X-Git-Url: http://www.binomiant.duckdns.org/9wAuyR5S/?a=commitdiff_plain;h=20e37d30d93a02bc9391920c3a1cb31cd4b5a382;p=ytdl-server.git clearing queue fixed --- diff --git a/app.js b/app.js index 235763e..27dbd10 100644 --- a/app.js +++ b/app.js @@ -27,8 +27,8 @@ app.use('/' + ver, indexRouter); // clean at start, then at 3 am every day common.cleanup(); const job = new cronJob('0 0 3 * * *', () => { - common.cleanup(); - queue.clear(); + common.cleanup(); + queue.clear(); }, null, false, 'Europe/London'); job.start(); diff --git a/lib/queue.js b/lib/queue.js index da39291..ec6dcfd 100644 --- a/lib/queue.js +++ b/lib/queue.js @@ -71,7 +71,9 @@ function enqueue(url) { } function clear() { - for (var i = 0; i < fifo.length; i++) { + const len = fifo.length; + + for (var i = 0; i < len; i++) { fifo.pop(); } map.clear();