diff --git a/server/tasks/speedtest.js b/server/tasks/speedtest.js index 8c0c5590..9fa7e8b7 100644 --- a/server/tasks/speedtest.js +++ b/server/tasks/speedtest.js @@ -3,6 +3,8 @@ const tests = require('../controller/speedtests'); const config = require('../controller/config'); const recommendations = require("../controller/recommendations"); +let isRunning = false; + function roundSpeed(bytes, elapsed) { return Math.round((bytes * 8 / elapsed) / 10) / 100; } @@ -22,6 +24,7 @@ async function createRecommendations() { } module.exports.run = async () => { + isRunning = true; let serverId = config.get("serverId").value; if (serverId === "none") serverId = undefined; @@ -35,6 +38,8 @@ module.exports.run = async () => { } module.exports.create = async () => { + if (isRunning) return 500; + try { let test = await this.run(); let ping = Math.round(test.ping.latency); @@ -47,6 +52,7 @@ module.exports.create = async () => { let testResult = tests.create(0, 0, 0); console.log(`Test #${testResult} was not executed successfully. Please try reconnecting to the internet or restarting the software.`); } + isRunning = false; } module.exports.removeOld = () => {